package me.zhengjie.modules.account.factory.service.Impl;


import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.common.collect.Maps;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.account.domain.AccountAc50;
import me.zhengjie.modules.account.domain.AccountAc50a5;
import me.zhengjie.modules.account.domain.AccountAc51;
import me.zhengjie.modules.account.factory.entity.AccountCalculatInter;
import me.zhengjie.modules.account.factory.entity.BasePersonAccount;
import me.zhengjie.modules.account.factory.entity.InterestRate;
import me.zhengjie.modules.account.factory.service.AccountComputer;
import me.zhengjie.modules.account.factory.service.AccountComputerOld;
import me.zhengjie.modules.account.factory.vo.*;
import me.zhengjie.modules.account.mapper.*;
import me.zhengjie.modules.account.service.AccountAc50Service;
import me.zhengjie.modules.account.service.AccountAc51Service;
import me.zhengjie.tool.*;
import me.zhengjie.utils.SecurityUtils;
import me.zhengjie.vo.Constant;
import me.zhengjie.vo.StandardVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

@Service
@RequiredArgsConstructor
public class AccountComputerOldImpl extends BasePersonAccount implements AccountComputerOld {
    private static final long serialVersionUID = 1234567L;
    final static Integer beginYear = 1980;
    static Integer nowaae001 = Ym.getCurrentYearInteger();
    //转移重复退费的只重绘处理一次
    private int zykjc = 0;
    protected Map<String, String> aaz116AndAaz673Map = new HashMap<>();

    private final AccountAa03Mapper accountAa03Mapper;
    private final AccountAc50Mapper accountAc50Mapper;
    private final AccountAc51Mapper accountAc51Mapper;
    private final AccountAc08Mapper accountAc08Mapper;
    private final AccountAc50a5Mapper accountAc50a5Mapper;
    private final AccountCommonMapper accountCommonMapper;
    private final AccountAc50Service accountAc50Service;
    private final AccountAc51Service accountAc51Service;

    /**
     * 账户计息保存
     * @param map
     * @return
     */
    @Override
    public Map computerAccount(MyMap map) {

        HashMap result = new HashMap<>();

        //1、初始化参数
        this.init(map);
        //2、准备计算参数
        this.preparationCalculateParameter();
        //3、注入计息账户
        this.registerAccount();
        //4、计算独立账户
        this.calculatedEachAccount();

        result.put("ac51", this.getIndividualAccountParameters());
        result.put("ac50", this.getIndividualAccounts());

        //保存账户数据
        saveAccount(this.getIndividualAccounts(), this.getIndividualAccountParameters());


        return result;
    }

    /**
     * 账户计息不保存
     * @param map
     * @return
     */
    @Override
    public Map computerAccountNotSave(MyMap map) {
        HashMap result = new HashMap<>();

        //1、初始化参数
        this.init(map);
        //2、准备计算参数
        this.preparationCalculateParameter();
        //3、注入计息账户
        this.registerAccount();
        //4、计算独立账户
        this.calculatedEachAccount();

        result.put("ac51", ListUtil.list2MyMapList(this.getIndividualAccountParameters()));
        result.put("ac50", ListUtil.list2MyMapList(this.getIndividualAccounts()));



        return result;
    }

    /**
     * 初始化参数
     *
     * @param myMap
     */
    public void init(MyMap myMap) {

        //考虑到静态方法 翻年不会计息
        this.nowaae001 = Ym.getCurrentYearInteger();
        //计息开始年月
        this.aae041 = myMap.getAsInteger("aae041");
        //计息结束年月
        this.aae042 = myMap.getAsInteger("aae042") == null ? Integer.parseInt((nowaae001 - 1) + "12") : myMap.getAsInteger("aae042");
        this.aaz159 = myMap.getAsString("aaz159");
        this.aac001 = myMap.getAsString("aac001");
        this.aae140 = myMap.getAsString("aae140");
        this.aaz117Batch = "";
        //计息截止年月日
        this.aic376 = Integer.parseInt(this.aae042 + "01");


    }

    /**
     * 准备计算参数
     */
    public void preparationCalculateParameter() {


        //1、根据人员信息生成账户的年度信息
        this.businessAae001Map = produceAnnualBusinessControls(this.aaz159, this.aac001, beginYear);

        //2、组织利率信息
        Map<String, Map<Integer, List<InterestRate>>> InterestRatesMap = produceAnnualInterestRate(this.aae140, beginYear);


        this.toYearsCurrentInterestRate = InterestRatesMap.get("CurrentInterest");
        this.toYearsOverInterestRate = InterestRatesMap.get("OverInterest");

    }

    /**
     * 注入计息账户
     */
    public void registerAccount() {

        this.IndividualAccountParameters = new ArrayList<>();
        this.IndividualAccounts = new ArrayList<>();
        Map queryMap = new HashMap();
        queryMap.put("aaz159", aaz159);
        queryMap.put("aac001", aac001);
        queryMap.put("aae100", Constant.AAE100_1_YX);
        List<AccountAc50> ac50List = accountAc50Mapper.selectByMap(queryMap);
        NPETool.isEmptyThrowException(ac50List, "未查询到参保账户");

        List<MyMap> ac50ListMap = ListUtil.list2MyMapList(ac50List);


        this.ac50Map = ac50ListMap.stream().collect(Collectors.groupingBy(m -> m.get("aaz116").toString() + "-" + m.get("aac062").toString()));
        queryMap.clear();
        queryMap.put("aaz159", aaz159);
        queryMap.put("aac001", aac001);
        queryMap.put("tyjrzhdy", "1");
        queryMap.put("zzzhdy", "1");


        List<Map> maps = accountCommonMapper.queryAc08(queryMap);


        allAc08List = maps;
        //  System.out.println(allAc08List);


    }

    /**
     * 计算独立账户
     */
    public void calculatedEachAccount() {


        this.ac50Map.forEach((keys, list) -> {
            String[] strs = keys.split("-");
            String aaz116 = strs[0];
            String aac062 = strs[1];
            Map map = list.get(0);
            MyMap myMap = new MyMap(map);
            Integer aae206 = myMap.getAsInteger("aae206");
            String aaa119 = myMap.getAsString("aaa119");
            String aaa513 = myMap.getAsString("aaa513");
            String aaz673 = myMap.getAsString("aaz673");
            aaz116AndAaz673Map.put(aaz116, aaz673);
            if (Constant.AAC062_1_RYXCB.equals(aac062)) {//正常账户计息
                calculateNormalAccount(aaz116, aaa119, aaa513, aac062, aae206);
            }
            if (Constant.AAC062_2_RYKTCZR.equals(aac062) || Constant.AAC062_3_RYKZDZR.equals(aac062)) {//转入账户计息
                calculateTransferAccount(aaz116, aaa119, aac062, aaa513, aae206);
            }
            if (Constant.AAC062_9_QT.equals(aac062)) {//采集账户计息
                calculateEntryAccount(aaz116, aaa119, aac062, aaa513, aae206);
            }


        });

    }

    /**
     * 获取业务年度对应的信息
     *
     * @param aaz159
     * @param aac001
     * @param beginYear
     * @return
     */
    @Override
    public Map<Integer, List<AnnualConversionTransverse>> produceAnnualBusinessControls(String aaz159, String aac001, Integer beginYear) {


        Map<Integer, List<AnnualConversionTransverse>> businessAae001Map = Maps.newHashMap();//业务年度对应的开始，结束时间
        Integer nowaae001 = Ym.getCurrentYearInteger();
        //准备年度信息
        QueryWrapper<AccountAc50a5> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("aaz159", aaz159);
        Map<Integer, AnnualConversion> annualConversionMap = new HashMap<>();

        List<Map<String, Object>> buinessYears = accountAc50a5Mapper.selectMaps(queryWrapper);
        if (ValidateUtil.isNotEmpty(buinessYears)) {
            buinessYears.stream().forEach(map -> {
                MyMap mymap = new MyMap(map);
                AnnualConversion annualConversion = new AnnualConversion();
                annualConversion.setAaz159(mymap.getAsString("aaz159"));
                annualConversion.setAae001(mymap.getAsInteger("aae001"));
                annualConversion.setBae095(mymap.getAsInteger("bae095"));
                annualConversionMap.put(mymap.getAsInteger("aae001"), annualConversion);
            });
        }
        //查询人员参保信息,用参保日期进行应缴月数计算
        Map queryMap = Maps.newHashMap();
        queryMap.put("aaz159", aaz159);
        List<Map> ac02List =accountCommonMapper.getAc02(queryMap);

        MyMap ac02MyMap = new MyMap(ac02List.get(0));
        NPETool.isEmptyThrowException(ac02MyMap.get("aae206"), "建账年月不能为空");
        ac02MyMap.put("aae206",ac02MyMap.get("aae206").toString().replaceAll("-","").substring(0,6));
        BigDecimal aac030 = ac02MyMap.getAsBigDecimal("aae206");

        Integer aac030_integer = aac030.intValue();
        Integer baae041;
        Integer baae042;
        StandardVO standardVO = new StandardVO("aae001", "Integer", "asc");
        List<Map> ascbuinessYears = ListUtil.sorts(buinessYears, standardVO);
        List<AnnualConversionTransverse> annualConversionTransversess = new ArrayList<>();
        int nd = beginYear;
        int maxNd = 0;
        if (ValidateUtil.isNotEmpty(ascbuinessYears)) {
            Integer businessAae041;
            for (Map map : ascbuinessYears) {
                MyMap mymap = new MyMap(map);
                Integer aae001 = mymap.getAsInteger("aae001");
                maxNd = aae001;
                Integer bae095 = mymap.getAsInteger("bae095");
                businessAae041 = Integer.parseInt(nd + "01");
                while (nd <= aae001) {
                    AnnualConversionTransverse annualConversiontransverse = new AnnualConversionTransverse();
                    if (bae095 > 12) {
                        if (nd < aae001) {
                            baae041 = businessAae041;
                            baae042 = Ym.addMonths(businessAae041, 12 - 1);
                            Integer bae084;
                            if (aac030_integer >= baae041 && aac030_integer <= baae042) {
                                bae084 = Ym.monthsBetween(aac030_integer, baae042) + 1;
                            } else {
                                bae084 = 12;
                            }
                            annualConversiontransverse.setAae041(baae041);
                            annualConversiontransverse.setAae042(baae042);
                            annualConversiontransverse.setAae001(nd);
                            annualConversiontransverse.setBae095(new BigDecimal(12));
                            annualConversiontransverse.setBae084(new BigDecimal(bae084));
                            businessAae041 = Ym.addMonths(baae042, 1);
                            annualConversiontransverse.setAae206(ac02MyMap.getAsInteger("aae206"));
                            annualConversiontransverse.setAaz159(aaz159);
                            annualConversionTransversess.add(annualConversiontransverse);
                        } else if (nd == aae001) {
                            baae041 = businessAae041;
                            baae042 = Ym.addMonths(businessAae041, (bae095 - 1));
                            annualConversiontransverse.setAae041(baae041);
                            annualConversiontransverse.setAae042(baae042);
                            annualConversiontransverse.setAae001(nd);
                            Integer bae084;
                            if (aac030_integer >= baae041 && aac030_integer <= baae042) {
                                bae084 = Ym.monthsBetween(aac030_integer, baae042) + 1;
                            } else {
                                bae084 = bae095;
                            }
                            annualConversiontransverse.setBae095(new BigDecimal(bae095));
                            annualConversiontransverse.setBae084(new BigDecimal(bae084));
                            businessAae041 = Ym.addMonths(baae042, 1);
                            annualConversiontransverse.setAae206(ac02MyMap.getAsInteger("aae206"));
                            annualConversiontransverse.setAaz159(aaz159);
                            annualConversionTransversess.add(annualConversiontransverse);
                        } else {
                            baae041 = businessAae041;
                            baae042 = Ym.addMonths(businessAae041, 12 - 1);
                            Integer bae084;
                            if (aac030_integer >= baae041 && aac030_integer <= baae042) {
                                bae084 = Ym.monthsBetween(aac030_integer, baae042) + 1;
                            } else {
                                bae084 = 12;
                            }
                            annualConversiontransverse.setAae041(baae041);
                            annualConversiontransverse.setAae042(baae042);
                            annualConversiontransverse.setAae001(nd);
                            annualConversiontransverse.setBae095(new BigDecimal(12));
                            annualConversiontransverse.setBae084(new BigDecimal(bae084));
                            businessAae041 = Ym.addMonths(baae042, 1);
                            annualConversiontransverse.setAae206(ac02MyMap.getAsInteger("aae206"));
                            annualConversiontransverse.setAaz159(aaz159);
                            annualConversionTransversess.add(annualConversiontransverse);
                        }
                    }
                    if (bae095 < 12) {
                        if (nd < aae001) {
                            Integer month = (12 - bae095) + 1;
                            String stMonth = month + "";
                            if (month < 10) {
                                stMonth = "0" + month;
                            }
                            businessAae041 = Integer.parseInt(nd + stMonth);
                            baae041 = businessAae041;
                            baae042 = Ym.addMonths(businessAae041, 12 - 1);

                            Integer bae084;
                            if (aac030_integer >= baae041 && aac030_integer <= baae042) {
                                bae084 = Ym.monthsBetween(aac030_integer, baae042) + 1;
                            } else {
                                bae084 = 12;
                            }

                            annualConversiontransverse.setAae041(baae041);
                            annualConversiontransverse.setAae042(baae042);
                            annualConversiontransverse.setAae001(nd);
                            annualConversiontransverse.setBae095(new BigDecimal(12));
                            annualConversiontransverse.setBae084(new BigDecimal(bae084));
                            businessAae041 = Ym.addMonths(baae042, 1);
                            annualConversiontransverse.setAae206(ac02MyMap.getAsInteger("aae206"));
                            annualConversiontransverse.setAaz159(aaz159);
                            annualConversionTransversess.add(annualConversiontransverse);
                        } else if (nd == aae001) {
                            Integer month = (12 - bae095) + 1;
                            String stMonth = month + "";
                            if (month < 10) {
                                stMonth = "0" + month;
                            }
                            businessAae041 = Integer.parseInt(nd + stMonth);
                            baae042 = Integer.parseInt(nd + "12");
                            Integer bae084;
                            baae041 = businessAae041;
                            if (aac030_integer >= baae041 && aac030_integer <= baae042) {
                                bae084 = Ym.monthsBetween(aac030_integer, baae042) + 1;
                            } else {
                                bae084 = bae095;
                            }
                            annualConversiontransverse.setAae041(baae041);
                            annualConversiontransverse.setAae042(baae042);
                            annualConversiontransverse.setBae095(new BigDecimal(bae095));
                            annualConversiontransverse.setBae084(new BigDecimal(bae084));
                            annualConversiontransverse.setAae001(nd);
                            businessAae041 = Ym.addMonths(baae042, 1);
                            annualConversiontransverse.setAae206(ac02MyMap.getAsInteger("aae206"));
                            annualConversiontransverse.setAaz159(aaz159);
                            annualConversionTransversess.add(annualConversiontransverse);
                        } else {
                            baae041 = businessAae041;
                            baae042 = Ym.addMonths(businessAae041, 12 - 1);
                            Integer bae084;
                            if (aac030_integer >= baae041 && aac030_integer <= baae042) {
                                bae084 = Ym.monthsBetween(aac030_integer, baae042) + 1;
                            } else {
                                bae084 = bae095;
                            }
                            annualConversiontransverse.setAae041(baae041);
                            annualConversiontransverse.setAae042(baae042);
                            annualConversiontransverse.setBae095(new BigDecimal(12));
                            annualConversiontransverse.setBae084(new BigDecimal(bae084));
                            annualConversiontransverse.setAae001(nd);
                            businessAae041 = Ym.addMonths(baae042, 1);
                            annualConversiontransverse.setAae206(ac02MyMap.getAsInteger("aae206"));
                            annualConversiontransverse.setAaz159(aaz159);
                            annualConversionTransversess.add(annualConversiontransverse);
                        }
                    }
                    nd = nd + 1;
                }

            }
            if ((maxNd + 1) <= nowaae001) {
                for (int aae001 = (maxNd + 1); aae001 <= nowaae001; aae001++) {
                    AnnualConversionTransverse annualConversiontransverse = new AnnualConversionTransverse();
                    baae041 = Integer.parseInt(aae001 + "01");
                    baae042 = Integer.parseInt(aae001 + "12");
                    annualConversiontransverse.setAae041(baae041);
                    annualConversiontransverse.setAae042(baae042);
                    annualConversiontransverse.setAae001(aae001);
                    annualConversiontransverse.setAaz159(aaz159);
                    annualConversiontransverse.setBae095(new BigDecimal(Ym.monthsBetween(baae041, baae042) + 1));
                    Integer bae084;
                    if (aac030_integer >= baae041 && aac030_integer <= baae042) {
                        bae084 = Ym.monthsBetween(aac030_integer, baae042) + 1;
                    } else {
                        bae084 = 12;
                    }
                    annualConversiontransverse.setBae084(new BigDecimal(bae084));
                    annualConversiontransverse.setAae206(ac02MyMap.getAsInteger("aae206"));
                    annualConversionTransversess.add(annualConversiontransverse);
                }
            }

        } else {
            for (int aae001 = beginYear; aae001 <= nowaae001; aae001++) {
                AnnualConversionTransverse annualConversiontransverse = new AnnualConversionTransverse();
                baae041 = Integer.parseInt(aae001 + "01");
                baae042 = Integer.parseInt(aae001 + "12");
                annualConversiontransverse.setAae041(baae041);
                annualConversiontransverse.setAae042(baae042);
                annualConversiontransverse.setAae001(aae001);
                annualConversiontransverse.setAaz159(aaz159);
                annualConversiontransverse.setBae095(new BigDecimal(Ym.monthsBetween(baae041, baae042) + 1));
                Integer bae084;
                if (aac030_integer >= baae041 && aac030_integer <= baae042) {
                    bae084 = Ym.monthsBetween(aac030_integer, baae042) + 1;
                } else {
                    bae084 = 12;
                }
                annualConversiontransverse.setBae084(new BigDecimal(bae084));
                annualConversiontransverse.setAae206(ac02MyMap.getAsInteger("aae206"));
                annualConversionTransversess.add(annualConversiontransverse);
            }
        }

        if (ValidateUtil.isNotEmpty(annualConversionTransversess)) {
            businessAae001Map = annualConversionTransversess.stream().collect(Collectors.groupingBy(annualConversionTransverse -> annualConversionTransverse.getAae001()));
        }
        return businessAae001Map;
    }

    /**
     * 获取退休情况
     *
     * @param aae140
     * @param aac001
     * @return
     */
    @Override
    public String produceAnnualInterestRetire(String aae140, String aac001) {
        return null;
    }

    /**
     * 将年转换成利率
     *
     * @param aae140
     * @param beginYear
     * @return
     */
    @Override
    public Map<String, Map<Integer, List<InterestRate>>> produceAnnualInterestRate(String aae140, Integer beginYear) {


        List<InterestRate> interestRateInfo = new ArrayList<>();//利率信息
        Map<Integer, List<InterestRate>> toYearsOverInterestRate = Maps.newHashMap();
        Map<Integer, List<InterestRate>> toYearsCurrentInterestRate = Maps.newHashMap();
        Integer nowaae001 = Ym.getCurrentYearInteger();
        String aaa030_80;
        String aaa030_90;
        if (Constant.AAE140_110_QYZGJBYLBX.equals(aae140)) {
            aaa030_80 = Constant.AAA030_80_SBDNJZLL;
            aaa030_90 = Constant.AAA030_90_SBJZLL;
        } else {
            aaa030_80 = Constant.AAA030_81_SBDNJZLL;
            aaa030_90 = Constant.AAA030_91_SBLNJZLL;
        }
        //准备利率信息
        HashMap query = new HashMap<>();

        List<Map<String, Object>> interestRates_tmp = accountAa03Mapper.selectMaps(new QueryWrapper<>());
        interestRates_tmp.forEach(map -> {

                map.put("aae041",Integer.parseInt(map.get("aae041").toString().replaceAll("-","").substring(0,6)));

                if(!ValidateUtil.isEmpty(map.get("aae042"))){
                    map.put("aae042",Integer.parseInt(map.get("aae042").toString().replaceAll("-","").substring(0,6)));

                }

            interestRateInfo.add(JSON.parseObject(JSON.toJSONString(map), InterestRate.class));
        });
        for (int aae001 = beginYear; aae001 <= nowaae001; aae001++) {
            Integer currentAae001 = aae001;
            List<InterestRate> interestRateCurrentList = interestRateInfo.stream().filter(interestRate -> (interestRate.getAae041() / 100) <= currentAae001 && currentAae001 <= (interestRate.getAae042() == null ? 9999 : interestRate.getAae042() / 100) && interestRate.getAaa030().equals(aaa030_80)).collect(Collectors.toList());
            if (ValidateUtil.isNotEmpty(interestRateCurrentList)) {
                toYearsCurrentInterestRate.put(currentAae001, interestRateCurrentList);
            } else {
                InterestRate interestRate = new InterestRate();
                interestRate.setAaa030(aaa030_80);
                interestRate.setAae041(Integer.parseInt(currentAae001 + "01"));
                interestRate.setAae042(Integer.parseInt(currentAae001 + "12"));
                interestRate.setAaa032("当年利率");
                interestRate.setAaa031(BigDecimal.valueOf(0));
                interestRate.setAab359("$$$$$$");
                interestRate.setAae013("");
                List<InterestRate> rateCurrentList = new ArrayList<>();
                rateCurrentList.add(interestRate);
                toYearsCurrentInterestRate.put(currentAae001, rateCurrentList);
            }
            List<InterestRate> interestRateOverList = interestRateInfo.stream().filter(interestRate -> (interestRate.getAae041() / 100) <= currentAae001 && currentAae001 <= (interestRate.getAae042() == null ? 9999 : interestRate.getAae042() / 100) && interestRate.getAaa030().equals(aaa030_90)).collect(Collectors.toList());
            if (ValidateUtil.isNotEmpty(interestRateOverList)) {
                toYearsOverInterestRate.put(currentAae001, interestRateOverList);
            } else {
                InterestRate interestRate = new InterestRate();
                interestRate.setAaa030(aaa030_90);
                interestRate.setAae041(Integer.parseInt(currentAae001 + "01"));
                interestRate.setAae042(Integer.parseInt(currentAae001 + "12"));
                interestRate.setAaa032("历年利率");
                interestRate.setAaa031(BigDecimal.valueOf(0));
                interestRate.setAab359("$$$$$$");
                interestRate.setAae013("");
                List<InterestRate> rateCurrentList = new ArrayList<>();
                rateCurrentList.add(interestRate);
                toYearsOverInterestRate.put(currentAae001, rateCurrentList);
            }
        }
        Map<String, Map<Integer, List<InterestRate>>> returnRate = new HashMap<>();
        returnRate.put("OverInterest", toYearsOverInterestRate);
        returnRate.put("CurrentInterest", toYearsCurrentInterestRate);
        return returnRate;

    }

    /**
     * 获取业务年度对应的信息
     *
     * @param aaz159
     * @param aac001
     * @param beginYear
     * @param buinessYears
     * @return
     */
    @Override
    public Map<Integer, List<AnnualConversionTransverse>> produceAnnualBusinessControls(String aaz159, String aac001, Integer beginYear, List<Map> buinessYears) {
        Map<Integer, List<AnnualConversionTransverse>> businessAae001Map = Maps.newHashMap();//业务年度对应的开始，结束时间
        Integer nowaae001 = Ym.getCurrentYearInteger();
        //准备年度信息
        Map queryMap = Maps.newHashMap();
        queryMap.put("aaz159", aaz159);
        queryMap.put("aac001", aac001);
        queryMap.put("aae100", Constant.AAE100_1_YX);
        Map<Integer, AnnualConversion> annualConversionMap = new HashMap<>();
        if (ValidateUtil.isNotEmpty(buinessYears)) {
            buinessYears.stream().forEach(map -> {
                MyMap mymap = new MyMap(map);
                AnnualConversion annualConversion = new AnnualConversion();
                annualConversion.setAaz159(mymap.getAsString("aaz159"));
                annualConversion.setAae001(mymap.getAsInteger("aae001"));
                annualConversion.setBae095(mymap.getAsInteger("bae095"));
                annualConversionMap.put(mymap.getAsInteger("aae001"), annualConversion);
            });
        }
        //查询人员参保信息,用参保日期进行应缴月数计算
//        List<Map> ac02List = NationalQueryRegister.einpBasicinfoQueryService().getAC02(queryMap);
        List<Map> ac02List = new ArrayList<>();
        Map ac02Map = ac02List.get(0);
        MyMap ac02MyMap = new MyMap(ac02Map);
        BigDecimal aac030 = ac02MyMap.getAsBigDecimal("aae206");
        Integer aac030_integer = aac030.intValue();

        Integer baae041;
        Integer baae042;
        StandardVO standardVO = new StandardVO("aae001", "Integer", "asc");
        List<Map> ascbuinessYears = ListUtil.sorts(buinessYears, standardVO);
        List<AnnualConversionTransverse> annualConversionTransversess = new ArrayList<>();
        int nd = beginYear;
        int maxNd = 0;
        if (ValidateUtil.isNotEmpty(ascbuinessYears)) {
            Integer businessAae041;
            for (Map map : ascbuinessYears) {
                MyMap mymap = new MyMap(map);
                Integer aae001 = mymap.getAsInteger("aae001");
                maxNd = aae001;
                Integer bae095 = mymap.getAsInteger("bae095");
                businessAae041 = Integer.parseInt(nd + "01");
                Integer oneTime = 0;
                while (nd <= aae001) {
                    AnnualConversionTransverse annualConversiontransverse = new AnnualConversionTransverse();
                    if (bae095 > 12) {
                        if (nd < aae001) {
                            baae041 = businessAae041;
                            baae042 = Ym.addMonths(businessAae041, 12 - 1);
                            Integer bae084;
                            if (aac030_integer >= baae041 && aac030_integer <= baae042) {
                                bae084 = Ym.monthsBetween(aac030_integer, baae042) + 1;
                            } else {
                                bae084 = 12;
                            }
                            annualConversiontransverse.setAae041(baae041);
                            annualConversiontransverse.setAae042(baae042);
                            annualConversiontransverse.setAae001(nd);
                            annualConversiontransverse.setBae095(new BigDecimal(12));
                            annualConversiontransverse.setBae084(new BigDecimal(bae084));
                            businessAae041 = Ym.addMonths(baae042, 1);
                            annualConversiontransverse.setAaz159(aaz159);
                            annualConversiontransverse.setAae206(ac02MyMap.getAsInteger("aae206"));
                            annualConversionTransversess.add(annualConversiontransverse);
                        } else if (nd == aae001) {
                            baae041 = businessAae041;
                            baae042 = Ym.addMonths(businessAae041, (bae095 - 1));
                            annualConversiontransverse.setAae041(baae041);
                            annualConversiontransverse.setAae042(baae042);
                            annualConversiontransverse.setAae001(nd);
                            Integer bae084;
                            if (aac030_integer >= baae041 && aac030_integer <= baae042) {
                                bae084 = Ym.monthsBetween(aac030_integer, baae042) + 1;
                            } else {
                                bae084 = bae095;
                            }
                            annualConversiontransverse.setBae095(new BigDecimal(bae095));
                            annualConversiontransverse.setBae084(new BigDecimal(bae084));
                            businessAae041 = Ym.addMonths(baae042, 1);
                            annualConversiontransverse.setAae206(ac02MyMap.getAsInteger("aae206"));
                            annualConversiontransverse.setAaz159(aaz159);
                            annualConversionTransversess.add(annualConversiontransverse);
                        } else {
                            baae041 = businessAae041;
                            baae042 = Ym.addMonths(businessAae041, 12 - 1);
                            Integer bae084;
                            if (aac030_integer >= baae041 && aac030_integer <= baae042) {
                                bae084 = Ym.monthsBetween(aac030_integer, baae042) + 1;
                            } else {
                                bae084 = 12;
                            }
                            annualConversiontransverse.setAae041(baae041);
                            annualConversiontransverse.setAae042(baae042);
                            annualConversiontransverse.setAae001(nd);
                            annualConversiontransverse.setBae095(new BigDecimal(12));
                            annualConversiontransverse.setBae084(new BigDecimal(bae084));
                            businessAae041 = Ym.addMonths(baae042, 1);
                            annualConversiontransverse.setAae206(ac02MyMap.getAsInteger("aae206"));
                            annualConversiontransverse.setAaz159(aaz159);
                            annualConversionTransversess.add(annualConversiontransverse);
                        }
                    }
                    if (bae095 < 12) {
                        if (nd < aae001) {
                            Integer month = (12 - bae095) + 1;
                            String stMonth = month + "";
                            if (month < 10) {
                                stMonth = "0" + month;
                            }
                            businessAae041 = Integer.parseInt(nd + stMonth);
                            baae041 = businessAae041;
                            baae042 = Ym.addMonths(businessAae041, 12 - 1);

                            Integer bae084;
                            if (aac030_integer >= baae041 && aac030_integer <= baae042) {
                                bae084 = Ym.monthsBetween(aac030_integer, baae042) + 1;
                            } else {
                                bae084 = 12;
                            }

                            annualConversiontransverse.setAae041(baae041);
                            annualConversiontransverse.setAae042(baae042);
                            annualConversiontransverse.setAae001(nd);
                            annualConversiontransverse.setBae095(new BigDecimal(12));
                            annualConversiontransverse.setBae084(new BigDecimal(bae084));
                            businessAae041 = Ym.addMonths(baae042, 1);
                            annualConversiontransverse.setAae206(ac02MyMap.getAsInteger("aae206"));
                            annualConversiontransverse.setAaz159(aaz159);
                            annualConversionTransversess.add(annualConversiontransverse);
                        } else if (nd == aae001) {
                            baae041 = businessAae041;
                            if (oneTime.intValue() == 0) {//第一年就是业务年度转自然年度
                                Integer month = (12 - bae095) + 1;
                                String stMonth = month + "";
                                if (month < 10) {
                                    stMonth = "0" + month;
                                }
                                baae041 = Integer.parseInt(nd + stMonth);
                            }
                            baae042 = Integer.parseInt(nd + "12");
                            Integer bae084;
                            if (aac030_integer >= baae041 && aac030_integer <= baae042) {
                                bae084 = Ym.monthsBetween(aac030_integer, baae042) + 1;
                            } else {
                                bae084 = bae095;
                            }
                            annualConversiontransverse.setAae041(baae041);
                            annualConversiontransverse.setAae042(baae042);
                            annualConversiontransverse.setBae095(new BigDecimal(bae095));
                            annualConversiontransverse.setBae084(new BigDecimal(bae084));
                            annualConversiontransverse.setAae001(nd);
                            businessAae041 = Ym.addMonths(baae042, 1);
                            annualConversiontransverse.setAae206(ac02MyMap.getAsInteger("aae206"));
                            annualConversiontransverse.setAaz159(aaz159);
                            annualConversionTransversess.add(annualConversiontransverse);
                        } else {
                            baae041 = businessAae041;
                            baae042 = Ym.addMonths(businessAae041, 12 - 1);
                            Integer bae084;
                            if (aac030_integer >= baae041 && aac030_integer <= baae042) {
                                bae084 = Ym.monthsBetween(aac030_integer, baae042) + 1;
                            } else {
                                bae084 = bae095;
                            }
                            annualConversiontransverse.setAae041(baae041);
                            annualConversiontransverse.setAae042(baae042);
                            annualConversiontransverse.setBae095(new BigDecimal(12));
                            annualConversiontransverse.setBae084(new BigDecimal(bae084));
                            annualConversiontransverse.setAae001(nd);
                            businessAae041 = Ym.addMonths(baae042, 1);
                            annualConversiontransverse.setAae206(ac02MyMap.getAsInteger("aae206"));
                            annualConversiontransverse.setAaz159(aaz159);
                            annualConversionTransversess.add(annualConversiontransverse);
                        }
                    }
                    oneTime = oneTime + 1;
                    nd = nd + 1;
                }
            }
            if ((maxNd + 1) <= nowaae001) {
                for (int aae001 = (maxNd + 1); aae001 <= nowaae001; aae001++) {
                    AnnualConversionTransverse annualConversiontransverse = new AnnualConversionTransverse();

                    baae041 = Integer.parseInt(aae001 + "01");
                    baae042 = Integer.parseInt(aae001 + "12");
                    annualConversiontransverse.setAae041(baae041);
                    annualConversiontransverse.setAae042(baae042);
                    annualConversiontransverse.setAae001(aae001);
                    annualConversiontransverse.setAaz159(aaz159);
                    annualConversiontransverse.setBae095(new BigDecimal(Ym.monthsBetween(baae041, baae042) + 1));
                    Integer bae084;
                    if (aac030_integer >= baae041 && aac030_integer <= baae042) {
                        bae084 = Ym.monthsBetween(aac030_integer, baae042) + 1;
                    } else {
                        bae084 = 12;
                    }
                    annualConversiontransverse.setBae084(new BigDecimal(bae084));
                    annualConversiontransverse.setAae206(ac02MyMap.getAsInteger("aae206"));
                    annualConversionTransversess.add(annualConversiontransverse);
                }
            }

        } else {
            for (int aae001 = beginYear; aae001 <= nowaae001; aae001++) {
                AnnualConversionTransverse annualConversiontransverse = new AnnualConversionTransverse();
                baae041 = Integer.parseInt(aae001 + "01");
                baae042 = Integer.parseInt(aae001 + "12");
                annualConversiontransverse.setAae041(baae041);
                annualConversiontransverse.setAae042(baae042);
                annualConversiontransverse.setAae001(aae001);
                annualConversiontransverse.setAaz159(aaz159);
                annualConversiontransverse.setBae095(new BigDecimal(Ym.monthsBetween(baae041, baae042) + 1));
                Integer bae084;
                if (aac030_integer >= baae041 && aac030_integer <= baae042) {
                    bae084 = Ym.monthsBetween(aac030_integer, baae042) + 1;
                } else {
                    bae084 = 12;
                }
                annualConversiontransverse.setBae084(new BigDecimal(bae084));
                annualConversiontransverse.setAae206(ac02MyMap.getAsInteger("aae206"));
                annualConversionTransversess.add(annualConversiontransverse);
            }
        }

        if (ValidateUtil.isNotEmpty(annualConversionTransversess)) {
            businessAae001Map = annualConversionTransversess.stream().collect(Collectors.groupingBy(annualConversionTransverse -> annualConversionTransverse.getAae001()));
        }
        return businessAae001Map;
    }


    /**
     * @Description 将年转换成利率
     */
    private void produceAnnualInterestRate() {
        String aaa030_80;
        String aaa030_90;
        if (Constant.AAE140_110_QYZGJBYLBX.equals(aae140)) {
            aaa030_80 = Constant.AAA030_80_SBDNJZLL;
            aaa030_90 = Constant.AAA030_90_SBJZLL;
        } else {
            aaa030_80 = Constant.AAA030_81_SBDNJZLL;
            aaa030_90 = Constant.AAA030_91_SBLNJZLL;
        }
        //准备利率信息
//        MiddlewareRepositoryRegister.redisUtils().delete(RedisConstant.KEY_PARAMETER_AA03);
        List<MyMap> interestRates_tmp = new ArrayList<>();
        interestRates_tmp.forEach(map -> {
            interestRateInfo.add(MyMap.convertToDomain(map, InterestRate.class));
        });
        for (int aae001 = beginYear; aae001 <= nowaae001; aae001++) {
            Integer currentAae001 = aae001;
            List<InterestRate> interestRateCurrentList = interestRateInfo.stream().filter(interestRate -> (interestRate.getAae041() / 100) <= currentAae001 && currentAae001 <= (interestRate.getAae042() == null ? 9999 : interestRate.getAae042() / 100) && interestRate.getAaa030().equals(aaa030_80)).collect(Collectors.toList());
            if (ValidateUtil.isNotEmpty(interestRateCurrentList)) {
                toYearsCurrentInterestRate.put(currentAae001, interestRateCurrentList);
            } else {
                InterestRate interestRate = new InterestRate();
                interestRate.setAaa030(aaa030_80);
                interestRate.setAae041(Integer.parseInt(currentAae001 + "01"));
                interestRate.setAae042(Integer.parseInt(currentAae001 + "12"));
                interestRate.setAaa032("当年利率");
                interestRate.setAaa031(BigDecimal.valueOf(0));
                interestRate.setAab359("$$$$$$");
                interestRate.setAae013("");
                List<InterestRate> rateCurrentList = new ArrayList<>();
                rateCurrentList.add(interestRate);
                toYearsCurrentInterestRate.put(currentAae001, rateCurrentList);
            }
            List<InterestRate> interestRateOverList = interestRateInfo.stream().filter(interestRate -> (interestRate.getAae041() / 100) <= currentAae001 && currentAae001 <= (interestRate.getAae042() == null ? 9999 : interestRate.getAae042() / 100) && interestRate.getAaa030().equals(aaa030_90)).collect(Collectors.toList());
            if (ValidateUtil.isNotEmpty(interestRateOverList)) {
                toYearsOverInterestRate.put(currentAae001, interestRateOverList);
            } else {
                InterestRate interestRate = new InterestRate();
                interestRate.setAaa030(aaa030_90);
                interestRate.setAae041(Integer.parseInt(currentAae001 + "01"));
                interestRate.setAae042(Integer.parseInt(currentAae001 + "12"));
                interestRate.setAaa032("历年利率");
                interestRate.setAaa031(BigDecimal.valueOf(0));
                interestRate.setAab359("$$$$$$");
                interestRate.setAae013("");
                List<InterestRate> rateCurrentList = new ArrayList<>();
                rateCurrentList.add(interestRate);
                toYearsOverInterestRate.put(currentAae001, rateCurrentList);
            }
        }

    }


    /**
     * @param aae003 aae003
     * @return {@link Integer }
     * @Description 获得业务年度
     * @Author jzy
     * @Date 2022/01/04
     */
    protected Integer getBusinessYear(Integer aae003) {
        for (Integer aae001 : businessAae001Map.keySet()) {
            List<AnnualConversionTransverse> annualConversionTransversess = businessAae001Map.get(aae001);
            if (ValidateUtil.isNotEmpty(annualConversionTransversess)) {
                AnnualConversionTransverse annualConversionTransverse = annualConversionTransversess.get(0);
                if (aae003 >= annualConversionTransverse.getAae041() &&
                        annualConversionTransverse.getAae042() >= aae003) {
                    return aae001;
                }

            } else {
                return aae003 / 100;
            }

        }
        return aae003 / 100;
    }

    /**
     * @param aaz116 aaz116
     * @Description 计算正常账户
     */
    protected void calculateNormalAccount(String aaz116, String aaa119, String aaa513, String aac062, Integer aae206) {
        String aae825 = Constant.AAE825_0_F;
        BigDecimal aae238 = BigDecimal.ZERO;
        BigDecimal aae239 = BigDecimal.ZERO;
        BigDecimal aae240 = BigDecimal.ZERO;
        List<BigDecimal> aae238s = new ArrayList<>();
        List<BigDecimal> aae239s = new ArrayList<>();
        List<IndividualAccountParameter> normalIndividuals = new ArrayList<>();
        if (ValidateUtil.isNotEmpty(allAc08List)) {//没有收入明细
            List<MyMap> allAc08myMaps = ListUtil.mapList2MyMapList(allAc08List);
            //正常实缴明细
            List<MyMap> normalPaymentDetails = allAc08myMaps.stream().filter(myMap ->
                    !myMap.getAsString("aae793").equals(Constant.AAE793_9022_CJZHTSMX) &&
                            !myMap.getAsString("aae793").equals(Constant.AAE793_9023_CJZHCF) &&
                            !myMap.getAsString("aae793").equals(Constant.AAE793_9024_JZQJFYS) &&
                            !myMap.getAsString("aae793").equals(Constant.AAE793_1061_ZR) &&
                            !myMap.getAsString("aae793").equals(Constant.AAE793_1062_JGZR) &&
                            !myMap.getAsString("aae793").equals(Constant.AAE793_1063_CXZR) &&
                            !myMap.getAsString("aae793").equals(Constant.AAE793_1064_JRZR) &&
                            !myMap.getAsString("aae793").equals(Constant.AAE793_1065_NJZR)
            ).collect(Collectors.toList());

            //更据获取的正常缴费明细进行计息
            if (ValidateUtil.isNotEmpty(normalPaymentDetails)) {
                Integer minAab191 = normalPaymentDetails.stream().min(Comparator.comparing(myMap -> myMap.getAsInteger("aab191"))).orElseGet(MyMap::new).getAsInteger("aab191");
                Integer minAae003 = minAab191 / 100;//最小到账日期
                Integer maxAab191 = normalPaymentDetails.stream().max(Comparator.comparing(myMap -> myMap.getAsInteger("aab191"))).orElseGet(MyMap::new).getAsInteger("aab191");
                incomeDeadline = maxAab191 / 100;//最大的到账日期
                Integer minhbaae003 = normalPaymentDetails.stream().min(Comparator.comparing(myMap -> myMap.getAsInteger("aae003"))).orElseGet(MyMap::new).getAsInteger("aae003");
                //从此开始计息
                Integer beginAae001 = getBusinessYear(minAae003);
                Integer hb_beginAae001 = getBusinessYear(minhbaae003);
                Integer endAae001;
                if (!ValidateUtil.isEmpty(this.aae042)) {
                    endAae001 = getBusinessYear(this.aae042);
                } else {
                    endAae001 = nowaae001;
                }
                //获取到账日期的最大年度
                Integer incomeDeadlineYear = getBusinessYear(incomeDeadline);
                if (incomeDeadlineYear < endAae001) {
                    incomeDeadlineYear = endAae001;
                }
                if (incomeDeadlineYear.intValue() < nowaae001.intValue()) {
                    incomeDeadlineYear = nowaae001;
                }

                Integer year = beginAae001;
                //BigDecimal aae875 = BigDecimal.ZERO; //本年补缴历年本金
                //BigDecimal aae876 = BigDecimal.ZERO; //本年补缴历年利息

                BigDecimal aae849 = BigDecimal.ZERO;//截至上年末个人账户单位缴费部分划转累计本息
                BigDecimal aae851 = BigDecimal.ZERO;//截至上年末个人账户个人缴费部分划转累计本息
                List<IndividualAccounttoCalculateParameter> individualAccounttoCalculateParameters = new ArrayList();
                Map<Integer, IndividualAccounttoCalculateParameter> individualAccounttoCalculateMaps = new HashMap<>();
                List<MyMap> overYears_aae262S_spends = new ArrayList(); //本年单位缴费部分划入个人账户本金划转历年集合
                List<MyMap> overYears_aae264S_spends = new ArrayList(); //本年个人缴费部分划入个人账户本金划转历年集合
                IndividualAccounttoCalculateParameter lastIndividualAccounttoCalculateParameter = new IndividualAccounttoCalculateParameter();
                Map deleteMap = new HashMap();
                deleteMap.put("aaz116", aaz116);
                List<MyMap> zc_ac51s = ListUtil.list2MyMapList(accountAc51Mapper.selectByMap(deleteMap));

                Integer deleteAae001 = 1990;
                if (ValidateUtil.isNotEmpty(zc_ac51s)) {
                    String sdeleteAae001 = zc_ac51s.stream().min(Comparator.comparing(m -> Integer.parseInt(m.get("aae001").toString())))
                            .orElseGet(MyMap::new).get("aae001").toString();
                    deleteAae001 = Integer.parseInt(sdeleteAae001);
                }
                deleteMap.clear();
                deleteMap.put(aaz116, deleteAae001);
                deleteAaz116s.add(deleteMap);
                while (year <= incomeDeadlineYear) {//滚动年度进行计算利息

                    IndividualAccounttoCalculateParameter individualAccounttoCalculateParameter = new IndividualAccounttoCalculateParameter();
                    if (null != lastIndividualAccounttoCalculateParameter) {//截止上年末不为空，赋值截止上年末
                        aae849 = convertNullToBigDecimal(lastIndividualAccounttoCalculateParameter.getAae849());
                        aae851 = convertNullToBigDecimal(lastIndividualAccounttoCalculateParameter.getAae851());

                        aae849 = aae849.add(convertNullToBigDecimal(lastIndividualAccounttoCalculateParameter.getAae262())).add(convertNullToBigDecimal(lastIndividualAccounttoCalculateParameter.getAae263())).add(convertNullToBigDecimal(lastIndividualAccounttoCalculateParameter.getAae259()));
                        aae851 = aae851.add(convertNullToBigDecimal(lastIndividualAccounttoCalculateParameter.getAae264())).add(convertNullToBigDecimal(lastIndividualAccounttoCalculateParameter.getAae265())).add(convertNullToBigDecimal(lastIndividualAccounttoCalculateParameter.getAae260()));

                    }
                    //取出业务年度
                    List<AnnualConversionTransverse> annualConversions = businessAae001Map.get(year);
                    Integer aae041;//开始年月
                    Integer aae042;//结束年月
                    BigDecimal bae084;//年度月数
                    if (nowaae001.intValue() <= year.intValue()) {//大于当前年度的数据，全部累加在本年度（对于一次性养老缴费导致的账户后移动）
                        if (ValidateUtil.isNotEmpty(annualConversions)) {
                            aae041 = annualConversions.get(0).getAae041();
                            aae042 = 999999;
                            bae084 = annualConversions.get(0).getBae084();
                        } else {
                            aae041 = Integer.parseInt(year + "01");
                            aae042 = 999999;
                            bae084 = BigDecimal.valueOf(12);
                        }
                    } else {
                        if (ValidateUtil.isNotEmpty(annualConversions)) {
                            aae041 = annualConversions.get(0).getAae041();
                            aae042 = annualConversions.get(0).getAae042();
                            bae084 = annualConversions.get(0).getBae084();
                        } else {
                            aae041 = Integer.parseInt(year + "01");
                            aae042 = Integer.parseInt(year + "12");
                            bae084 = BigDecimal.valueOf(12);
                        }
                    }


                    List<MyMap> nowAccountList = normalPaymentDetails.stream().filter(myMap -> (myMap.getAsInteger("aab191") / 100) >= aae041
                            && aae042 >= (myMap.getAsInteger("aab191") / 100) && !myMap.getAsString("aae793").equals(Constant.AAE793_9022_CJZHTSMX)
                            && !myMap.getAsString("aae793").equals(Constant.AAE793_9024_JZQJFYS)
                            && !myMap.getAsString("aae793").equals(Constant.AAE793_9023_CJZHCF)).collect(Collectors.toList());


                    Integer aae202 = 0;//实缴月数（需要排除建账前的月数）
                    List<MyMap> nowAccountList_aae202 = allAc08myMaps.stream().filter(myMap -> myMap.getAsInteger("aae003") >= aae041
                            && aae042 >= myMap.getAsInteger("aae003") && !myMap.getAsString("aae793").equals(Constant.AAE793_9024_JZQJFYS)).collect(Collectors.toList());

                    if (ValidateUtil.isNotEmpty(nowAccountList_aae202)) {
                        for (MyMap myMap : nowAccountList_aae202) {
                            aae202 = aae202 + myMap.getAsInteger("aae202");
                        }
                    }


                    BigDecimal nowAae081 = BigDecimal.ZERO;
                    BigDecimal nowAae083 = BigDecimal.ZERO;
                    BigDecimal nowAae789 = BigDecimal.ZERO;
                    BigDecimal nowAae791 = BigDecimal.ZERO;
                    List<MyMap> overYears_aae262S_spends_list = new ArrayList(); //本年单位缴费部分划入个人账户本金划转历年集合
                    List<MyMap> overYears_aae264S_spends_list = new ArrayList(); //本年个人缴费部分划入个人账户本金划转历年集合
                    if (ValidateUtil.isNotEmpty(nowAccountList)) {
                        for (MyMap myMap : nowAccountList) {
                            BigDecimal aae081 = myMap.getAsBigDecimalNullToZero("aae081"); //单位实缴划入个人账户金额
                            BigDecimal aae083 = myMap.getAsBigDecimalNullToZero("aae083"); //个人实缴划入个人账户金额
                            BigDecimal aae789 = myMap.getAsBigDecimalNullToZero("aae789"); //单位实缴划入个人账户金额利息
                            BigDecimal aae791 = myMap.getAsBigDecimalNullToZero("aae791"); //个人实缴划入个人账户金额利息
                            nowAae081 = nowAae081.add(aae081);//单位实缴划入个人账户金额
                            nowAae789 = nowAae789.add(aae789);//单位实缴划入个人账户金额利息
                            nowAae083 = nowAae083.add(aae083);//个人实缴划入个人账户金额+个人实缴划入个人账户金额利息
                            nowAae791 = nowAae791.add(aae791);

                            //记载本年补缴历年的金额
                            if (!(myMap.getAsInteger("aae003") >= aae041 &&
                                    myMap.getAsInteger("aae003") <= aae042)) {

                                if (nowAae081.compareTo(BigDecimal.ZERO) != 0) {//单位部分大于0
                                    overYears_aae262S_spends_list.add(myMap);
                                }

                                if (nowAae083.compareTo(BigDecimal.ZERO) != 0) {//个人部分大于0
                                    overYears_aae264S_spends_list.add(myMap);
                                }
//                                aae875.add(nowAae081).add(nowAae083);
//                                aae876.add(aae789).add(aae791);

                            }
                            //单位当年实缴金额,个人当年实缴金额,其他当年实缴金额,当年单位划转其他年度金额,当年个人划转其他年度金额,当年其他划转其他年度金额,当年利率,历年利率,单位历年实缴金额,个人历年实缴金额,其他历年实缴金额,历年单位划转其他年度金额,历年个人划转其他年度金额,历年其他划转其他年度金额
                        }
                    } else {
                        nowAae081 = BigDecimal.ZERO;
                        nowAae083 = BigDecimal.ZERO;
                    }
                    overYears_aae262S_spends.addAll(overYears_aae262S_spends_list);
                    overYears_aae264S_spends.addAll(overYears_aae264S_spends_list);
                    //当年利率
                    List<InterestRate> currentInterestRates = toYearsCurrentInterestRate.get(year);
                    BigDecimal current_aaa031; // 当年利率
                    BigDecimal overYears_aaa031; // 历年利率
                    if (year.intValue() < endAae001 || year.intValue() > endAae001) {//如果不是计息截止日期，就取利率同年开始日期最大的那条
                        List<InterestRate> aaa031s = currentInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                        if (ValidateUtil.isNotEmpty(aaa031s)) {
                            current_aaa031 = aaa031s.get(0).getAaa031();
                        } else {
                            current_aaa031 = BigDecimal.ZERO;
//                            throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                        }
                    } else {//大于计息截止日期
                        currentInterestRates = toYearsCurrentInterestRate.get(endAae001);
                        if (ValidateUtil.isNotEmpty(currentInterestRates)) {
                            List<InterestRate> aaa031s = currentInterestRates.stream().filter(interestRate -> interestRate.getAae041() <= this.aae042 && this.aae042 <= interestRate.getAae042()).collect(Collectors.toList());
                            if (ValidateUtil.isNotEmpty(aaa031s)) {
                                current_aaa031 = aaa031s.get(0).getAaa031();
                            } else {
                                current_aaa031 = BigDecimal.ZERO;
                                //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!"+this.aae042+"结束日期"+endAae001);
                            }
                        } else {
                            current_aaa031 = BigDecimal.ZERO;
                            //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                        }
                    }
                    //历年利率
                    List<InterestRate> overInterestRates = toYearsOverInterestRate.get(year);
                    if (year.intValue() < endAae001 || year.intValue() > endAae001) {
                        List<InterestRate> aaa031s = overInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                        if (ValidateUtil.isNotEmpty(aaa031s)) {
                            overYears_aaa031 = aaa031s.get(0).getAaa031();
                        } else {
                            overYears_aaa031 = BigDecimal.ZERO;
                            //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                        }
                    } else {
                        overInterestRates = toYearsOverInterestRate.get(endAae001);
                        if (ValidateUtil.isNotEmpty(overInterestRates)) {
                            List<InterestRate> aaa031s = overInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                            if (ValidateUtil.isNotEmpty(aaa031s)) {
                                overYears_aaa031 = aaa031s.get(0).getAaa031();
                            } else {
                                overYears_aaa031 = BigDecimal.ZERO;
                                //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                            }
                        } else {
                            overYears_aaa031 = BigDecimal.ZERO;
                            //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                        }
                    }
                    //计算利息
                    //历年利息（2006前:本金*利率*年度月数/12;2006后:本金*利率;最后截止年月，是本金*利率*所占月数/12）
                    BigDecimal aae259 = BigDecimal.ZERO;// 截至上年末个人账户单位缴费部分划转本息在本年产生的利息,
                    BigDecimal aae260 = BigDecimal.ZERO;// 截至上年末个人账户个人缴费部分划转本息在本年产生的利息
                    aae259 = AccountCalculatInter.calculatPastYearInter(aae849, overYears_aaa031, bae084, year, this.aae042, endAae001);
                    aae260 = AccountCalculatInter.calculatPastYearInter(aae851, overYears_aaa031, bae084, year, this.aae042, endAae001);
                    /*if (year.intValue() <= endAae001.intValue()) {
                        if (year.intValue() <= 2006) {
                            aae259 = aae849.multiply(overYears_aaa031).multiply(bae084).divide(BigDecimal.valueOf(12)).setScale(2, BigDecimal.ROUND_HALF_UP);
                            aae260 = aae851.multiply(overYears_aaa031).multiply(bae084).divide(BigDecimal.valueOf(12)).setScale(2, BigDecimal.ROUND_HALF_UP);
                            if (year.intValue() == endAae001.intValue()) {
                                Integer ys = this.aae042 % 100;
                                aae259 = aae259.multiply(BigDecimal.valueOf(ys)).divide(BigDecimal.valueOf(12), 4, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
                                aae260 = aae260.multiply(BigDecimal.valueOf(ys)).divide(BigDecimal.valueOf(12), 4, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
                            }
                        } else {
                            aae259 = aae849.multiply(overYears_aaa031).setScale(2, BigDecimal.ROUND_HALF_UP);
                            aae260 = aae851.multiply(overYears_aaa031).setScale(2, BigDecimal.ROUND_HALF_UP);
                            if (year.intValue() == endAae001.intValue()) {
                                Integer ys = this.aae042 % 100;
                                aae259 = aae259.multiply(BigDecimal.valueOf(ys)).divide(BigDecimal.valueOf(12), 4, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
                                aae260 = aae260.multiply(BigDecimal.valueOf(ys)).divide(BigDecimal.valueOf(12), 4, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
                            }
                        }
                    }*/
                    //本年单位缴费部分划入个人账户本金所产生的利息
                    BigDecimal aae263 = BigDecimal.ZERO;
                    BigDecimal aae265 = BigDecimal.ZERO;
                    //当年利息（2006前:本金*利率*实缴/12/2;2006后:本金*利率*1.083/2）
                    aae263 = AccountCalculatInter.calculatThisYearInter(nowAae081, current_aaa031, aae202, year, endAae001);
                    aae265 = AccountCalculatInter.calculatThisYearInter(nowAae083, current_aaa031, aae202, year, endAae001);
                    aae263 = aae263.add(nowAae789);
                    aae265 = aae265.add(nowAae791);

                    /*if (year.intValue() <= endAae001.intValue()) {
                        if (year <= 2006) {
                            //本年单位缴费部分划入个人账户本金所产生的利息
                            aae263 = nowAae081.multiply(current_aaa031).multiply(BigDecimal.valueOf(aae202)).divide(BigDecimal.valueOf(12)).divide(BigDecimal.valueOf(2)).setScale(2, BigDecimal.ROUND_HALF_UP);
                            //本年个人缴费部分划入个人账户本金所产生的利息
                            aae265 = nowAae083.multiply(current_aaa031).multiply(BigDecimal.valueOf(aae202)).divide(BigDecimal.valueOf(12)).divide(BigDecimal.valueOf(2)).setScale(2, BigDecimal.ROUND_HALF_UP);
                        } else {
                            //本年单位缴费部分划入个人账户本金所产生的利息
                            aae263 = nowAae081.multiply(current_aaa031).multiply(BigDecimal.valueOf(1.083)).divide(BigDecimal.valueOf(2)).setScale(2, BigDecimal.ROUND_HALF_UP);
                            //本年个人缴费部分划入个人账户本金所产生的利息
                            aae265 = nowAae083.multiply(current_aaa031).multiply(BigDecimal.valueOf(1.083)).divide(BigDecimal.valueOf(2)).setScale(2, BigDecimal.ROUND_HALF_UP);
                        }
                    }*/
                    //截止上年末本息=本年收入+本年利息+历年利息
                    individualAccounttoCalculateParameter.setAae001(year);
                    individualAccounttoCalculateParameter.setActualPaymentMonths(aae202);
                    individualAccounttoCalculateParameter.setAae849(aae849);
                    individualAccounttoCalculateParameter.setAae851(aae851);
                    individualAccounttoCalculateParameter.setAae259(aae259);
                    individualAccounttoCalculateParameter.setAae260(aae260);


                    individualAccounttoCalculateParameter.setAae262(nowAae081);
                    individualAccounttoCalculateParameter.setAae263(aae263);
                    individualAccounttoCalculateParameter.setAae264(nowAae083);
                    individualAccounttoCalculateParameter.setAae265(aae265);
                    individualAccounttoCalculateParameter.setCurrent_aaa031(current_aaa031);
                    individualAccounttoCalculateParameter.setOverYears_aaa031(overYears_aaa031);
                    individualAccounttoCalculateParameter.setOverYears_aae262S_spends(overYears_aae262S_spends_list);
                    individualAccounttoCalculateParameter.setOverYears_aae264S_spends(overYears_aae264S_spends_list);
                    //individualAccounttoCalculateParameter.getOverYears_aae262S_spends().addAll(overYears_aae262S_spends); //本年单位缴费部分划入个人账户本金划转历年集合
                    //individualAccounttoCalculateParameter.getOverYears_aae264S_spends().addAll(overYears_aae264S_spends); //本年个人缴费部分划入个人账户本金划转历年集合
                    //individualAccounttoCalculateParameter.getOverYears_aae855S_spends().addAll(individualAccounttoCalculateParameter.getOverYears_aae855S_spends()); //本年其他部分划入个人账户本金划转历年集合
                    individualAccounttoCalculateParameter.setAae876(BigDecimal.ZERO);
                    individualAccounttoCalculateParameter.setAae875(BigDecimal.ZERO);
                    individualAccounttoCalculateMaps.put(year, individualAccounttoCalculateParameter);
                    year = year + 1;
                    BeanUtils.copyProperties(individualAccounttoCalculateParameter, lastIndividualAccounttoCalculateParameter);
                }
                boolean b = false;
                Map<Integer, List<MyMap>> overYears_aae262Map = null;
                Map<Integer, List<MyMap>> overYears_aae264Map = null;
                if (ValidateUtil.isNotEmpty(overYears_aae262S_spends)) {//将此划分成按照年度
                    overYears_aae262Map = overYears_aae262S_spends.stream().collect(Collectors.groupingBy(myMap -> getBusinessYear(myMap.getAsInteger("aae003"))));
                    b = true;
                }
                if (ValidateUtil.isNotEmpty(overYears_aae264S_spends)) {//将此划分成按照年度
                    overYears_aae264Map = overYears_aae264S_spends.stream().collect(Collectors.groupingBy(myMap -> getBusinessYear(myMap.getAsInteger("aae003"))));
                    b = true;
                }
                if (b) {
                    Integer aae001 = hb_beginAae001;
                    IndividualAccounttoCalculateParameter lastIndividual = null;
                    BigDecimal aae853 = BigDecimal.ZERO;
                    aae849 = BigDecimal.ZERO;
                    aae851 = BigDecimal.ZERO;
                    aae853 = BigDecimal.ZERO;
                    while (aae001 <= incomeDeadlineYear) {
                        IndividualAccounttoCalculateParameter individual = individualAccounttoCalculateMaps.get(aae001);
                        if (null != lastIndividual) {

                            aae849 = convertNullToBigDecimal(lastIndividual.getAae849());
                            aae851 = convertNullToBigDecimal(lastIndividual.getAae851());
                            aae853 = convertNullToBigDecimal(lastIndividual.getAae853());

                            aae849 = aae849.add(convertNullToBigDecimal(lastIndividual.getAae262())).add(convertNullToBigDecimal(lastIndividual.getAae263())).add(convertNullToBigDecimal(lastIndividual.getAae259()));
                            aae851 = aae851.add(convertNullToBigDecimal(lastIndividual.getAae264())).add(convertNullToBigDecimal(lastIndividual.getAae265())).add(convertNullToBigDecimal(lastIndividual.getAae260()));
                            aae853 = aae853.add(convertNullToBigDecimal(lastIndividual.getAae855()).add(convertNullToBigDecimal(lastIndividual.getAae856())));
                        } else {
                            lastIndividual = new IndividualAccounttoCalculateParameter();
                        }
                        List<MyMap> hzaae262s = new ArrayList<>();
                        List<MyMap> hzaae264s = new ArrayList<>();
                        BigDecimal aae262 = BigDecimal.ZERO;
                        BigDecimal aae264 = BigDecimal.ZERO;
                        if (null != overYears_aae262Map && !overYears_aae262Map.isEmpty()) {
                            if (aae001.intValue() == incomeDeadlineYear.intValue()) {
                                Integer finalAae00 = aae001;
                                List<MyMap> finalHzaae262s = hzaae262s;
                                overYears_aae262Map.forEach((k, list) -> {
                                    if (k.intValue() >= finalAae00.intValue()) {
                                        List<MyMap> myList = ListUtil.list2MyMapList(list);
                                        finalHzaae262s.addAll(myList);
                                    }
                                });
                                if (ValidateUtil.isNotEmpty(finalHzaae262s)) {
                                    aae262 = finalHzaae262s.stream().map(m -> m.getAsBigDecimalNullToZero("aae081")).reduce(BigDecimal.ZERO, BigDecimal::add);
                                }
                            } else {
                                hzaae262s = overYears_aae262Map.get(aae001);
                                if (ValidateUtil.isNotEmpty(hzaae262s)) {
                                    aae262 = hzaae262s.stream().map(m -> m.getAsBigDecimalNullToZero("aae081")).reduce(BigDecimal.ZERO, BigDecimal::add);
                                }
                            }
                        }
                        if (null != overYears_aae264Map && !overYears_aae264Map.isEmpty()) {
                            if (aae001.intValue() == incomeDeadlineYear.intValue()) {
                                Integer finalAae00 = aae001;
                                List<MyMap> finalHzaae264s = hzaae264s;
                                overYears_aae264Map.forEach((k, list) -> {
                                    if (k.intValue() >= finalAae00.intValue()) {
                                        List<MyMap> myList = ListUtil.list2MyMapList(list);
                                        finalHzaae264s.addAll(myList);
                                    }
                                });
                                if (ValidateUtil.isNotEmpty(finalHzaae264s)) {
                                    aae264 = finalHzaae264s.stream().map(m -> m.getAsBigDecimalNullToZero("aae083")).reduce(BigDecimal.ZERO, BigDecimal::add);
                                }
                            } else {
                                hzaae264s = overYears_aae264Map.get(aae001);
                                if (ValidateUtil.isNotEmpty(hzaae264s)) {
                                    aae264 = hzaae264s.stream().map(m -> m.getAsBigDecimalNullToZero("aae083")).reduce(BigDecimal.ZERO, BigDecimal::add);
                                }
                            }
                        }
                        //当年利率
                        List<InterestRate> currentInterestRates = toYearsCurrentInterestRate.get(aae001);
                        BigDecimal current_aaa031; // 当年利率
                        BigDecimal overYears_aaa031; // 历年利率
                        if (year.intValue() < endAae001 || year.intValue() > endAae001) {//如果不是计息截止日期，就取利率同年开始日期最大的那条
                            List<InterestRate> aaa031s = currentInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                            if (ValidateUtil.isNotEmpty(aaa031s)) {
                                current_aaa031 = aaa031s.get(0).getAaa031();
                            } else {
                                current_aaa031 = BigDecimal.ZERO;
//                                throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                            }
                        } else {//计息截止日期
                            currentInterestRates = toYearsCurrentInterestRate.get(endAae001);
                            if (ValidateUtil.isNotEmpty(currentInterestRates)) {
                                List<InterestRate> aaa031s = currentInterestRates.stream().filter(interestRate -> interestRate.getAae041() <= this.aae042 && this.aae042 <= interestRate.getAae042()).collect(Collectors.toList());
                                if (ValidateUtil.isNotEmpty(aaa031s)) {
                                    current_aaa031 = aaa031s.get(0).getAaa031();
                                } else {
                                    current_aaa031 = BigDecimal.ZERO;
//                                    throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                                }
                            } else {
                                current_aaa031 = BigDecimal.ZERO;
                                throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                            }
                        }
                        //历年利率
                        List<InterestRate> overInterestRates = toYearsOverInterestRate.get(aae001);
                        if (year.intValue() < endAae001 || year.intValue() > endAae001) {
                            List<InterestRate> aaa031s = overInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                            if (ValidateUtil.isNotEmpty(aaa031s)) {
                                overYears_aaa031 = aaa031s.get(0).getAaa031();
                            } else {
                                overYears_aaa031 = BigDecimal.ZERO;
                                //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                            }
                        } else {
                            overInterestRates = toYearsOverInterestRate.get(getBusinessYear(endAae001));
                            if (ValidateUtil.isNotEmpty(overInterestRates)) {
                                List<InterestRate> aaa031s = overInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                                if (ValidateUtil.isNotEmpty(aaa031s)) {
                                    overYears_aaa031 = aaa031s.get(0).getAaa031();
                                } else {
                                    overYears_aaa031 = BigDecimal.ZERO;
                                    //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                                }
                            } else {
                                overYears_aaa031 = BigDecimal.ZERO;
                                //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                            }
                        }
                        if (null == individual) {
                            individual = new IndividualAccounttoCalculateParameter();
                            individual.setAae001(aae001);
                            individual.setAae849(aae849);//截至上年末个人账户单位缴费部分划转累计本息
                            individual.setAae259(BigDecimal.ZERO);//截至上年末个人账户单位缴费部分划转本息在本年产生的利息
                            individual.setAae262(aae262);//本年单位缴费部分划入个人账户本金
                            individual.setAae263(BigDecimal.ZERO);//本年单位缴费部分划入个人账户本金所产生的利息
                            individual.setAae851(aae851);//截至上年末个人账户个人缴费部分划转累计本息
                            individual.setAae260(BigDecimal.ZERO);//截至上年末个人账户个人缴费部分划转本息在本年产生的利息
                            individual.setAae264(aae264);//本年个人缴费部分划入个人账户本金
                            individual.setAae265(BigDecimal.ZERO);//本年个人缴费部分划入个人账户本金所产生的利息
                            individual.setAae853(aae853);//截至上年末个人账户其他部分划转累计本息
                            individual.setAae854(new BigDecimal("0"));//截至上年末个人账户其他部分划转本息在本年产生的利息
                            individual.setAae855(new BigDecimal("0"));//本年其他部分划入个人账户本金
                            individual.setAae856(new BigDecimal("0"));//本年其他部分划入个人账户本金所产生的利息
                            individual.setCurrent_aaa031(current_aaa031);
                            individual.setOverYears_aaa031(overYears_aaa031);
                            individual.setAae875(new BigDecimal("0"));//本年补缴历年本金
                            individual.setAae876(new BigDecimal("0"));//本年补缴历年利息
                            individual.setActualPaymentMonths(0);
                        } else {
                            BigDecimal aae262_kj = BigDecimal.ZERO;
                            if (ValidateUtil.isNotEmpty(individual.getOverYears_aae262S_spends())) {
                                aae262_kj = individual.getOverYears_aae262S_spends().stream().map(myMap -> myMap.getAsBigDecimalNullToZero("aae081")).reduce(BigDecimal.ZERO, BigDecimal::add);
                            }
                            BigDecimal aae264_kj = BigDecimal.ZERO;
                            if (ValidateUtil.isNotEmpty(individual.getOverYears_aae264S_spends())) {
                                aae264_kj = individual.getOverYears_aae264S_spends().stream().map(myMap -> myMap.getAsBigDecimalNullToZero("aae083")).reduce(BigDecimal.ZERO, BigDecimal::add);
                            }

                            individual.setAae849(aae849);//截至上年末个人账户单位缴费部分划转累计本息
                            individual.setAae262(individual.getAae262().subtract(aae262_kj).add(aae262));//本年单位缴费部分划入个人账户本金
                            //individual.setAae263(BigDecimal.ZERO);//本年单位缴费部分划入个人账户本金所产生的利息
                            individual.setAae851(aae851);//截至上年末个人账户个人缴费部分划转累计本息
                            //individual.setAae260(BigDecimal.ZERO);//截至上年末个人账户个人缴费部分划转本息在本年产生的利息
                            individual.setAae264(individual.getAae264().subtract(aae264_kj).add(aae264));//本年个人缴费部分划入个人账户本金
                            //individual.setAae265(BigDecimal.ZERO);//本年个人缴费部分划入个人账户本金所产生的利息
                            individual.setAae853(aae853);//截至上年末个人账户其他部分划转累计本息
                        }
                        individualAccounttoCalculateParameters.add(individual);
                        BeanUtils.copyProperties(individual, lastIndividual);
                        aae001 = aae001 + 1;
                    }
                } else {
                    individualAccounttoCalculateMaps.forEach((key, indi) -> {
                        individualAccounttoCalculateParameters.add(indi);
                    });
                }

                individualAccounttoCalculateParameters.stream().sorted(Comparator.comparing(ind -> ind.getAae001()));
                individualAccounttoCalculateParameters.stream().forEach(individual -> {
                    BigDecimal aae238_temp = BigDecimal.ZERO;
                    BigDecimal aae239_temp = BigDecimal.ZERO;
                    BigDecimal aae240_temp = BigDecimal.ZERO;

                    IndividualAccountParameter individualAccountParameter = new IndividualAccountParameter();
                    individualAccountParameter.setAae849(convertNullToBigDecimal(individual.getAae849())); //number(16,2), 截至上年末个人账户单位缴费部分划转累计本息,
                    individualAccountParameter.setAae259(convertNullToBigDecimal(individual.getAae259())); //number(16,2), 截至上年末个人账户单位缴费部分划转本息在本年产生的利息,
                    individualAccountParameter.setAae262(convertNullToBigDecimal(individual.getAae262())); //number(16,2), 本年单位缴费部分划入个人账户本金,
                    individualAccountParameter.setAae263(convertNullToBigDecimal(individual.getAae263())); //number(16,2), 本年单位缴费部分划入个人账户本金所产生的利息,
                    individualAccountParameter.setAae850(convertNullToBigDecimal(individual.getAae849()).add(convertNullToBigDecimal(individual.getAae259())).add(convertNullToBigDecimal(individual.getAae262())).add(convertNullToBigDecimal(individual.getAae263()))); //number(16,2), 截至本年末个人账户单位缴费部分划转累计本息,
                    individualAccountParameter.setAae851(convertNullToBigDecimal(individual.getAae851())); //number(16,2), 截至上年末个人账户个人缴费部分划转累计本息,
                    individualAccountParameter.setAae260(convertNullToBigDecimal(individual.getAae260())); //number(16,2), 截至上年末个人账户个人缴费部分划转本息在本年产生的利息,
                    individualAccountParameter.setAae264(convertNullToBigDecimal(individual.getAae264())); //number(16,2), 本年个人缴费部分划入个人账户本金,
                    individualAccountParameter.setAae265(convertNullToBigDecimal(individual.getAae265())); //number(16,2), 本年个人缴费部分划入个人账户本金所产生的利息,
                    individualAccountParameter.setAae852(convertNullToBigDecimal(individual.getAae851()).add(convertNullToBigDecimal(individual.getAae260())).add(convertNullToBigDecimal(individual.getAae264())).add(convertNullToBigDecimal(individual.getAae265()))); //number(16,2), 截至本年末个人账户个人缴费部分划转累计本息,
                    individualAccountParameter.setAae853(convertNullToBigDecimal(individual.getAae853())); //number(16,2), 截至上年末个人账户其他部分划转累计本息,
                    individualAccountParameter.setAae854(convertNullToBigDecimal(individual.getAae854())); //number(16,2), 截至上年末个人账户其他部分划转本息在本年产生的利息,
                    individualAccountParameter.setAae855(convertNullToBigDecimal(individual.getAae855())); //number(16,2), 本年其他部分划入个人账户本金,
                    individualAccountParameter.setAae856(convertNullToBigDecimal(individual.getAae856())); //number(16,2), 本年其他部分划入个人账户本金所产生的利息,
                    individualAccountParameter.setAae857(convertNullToBigDecimal(individual.getAae853()).add(convertNullToBigDecimal(individual.getAae854())).add(convertNullToBigDecimal(individual.getAae855())).add(convertNullToBigDecimal(individual.getAae856()))); //number(16,2), 截至本年末个人账户其他部分划转累计本息,
                    individualAccountParameter.setAae873(convertNullToBigDecimal(individual.getAae262()).add(convertNullToBigDecimal(individual.getAae264()))); //number(16,2), 本年本金总和,
                    individualAccountParameter.setAae874(convertNullToBigDecimal(individual.getAae259()).add(convertNullToBigDecimal(individual.getAae263()).add(convertNullToBigDecimal(individual.getAae260())).add(convertNullToBigDecimal(individual.getAae265())).add(convertNullToBigDecimal(individual.getAae854())).add(convertNullToBigDecimal(individual.getAae856()))));//本年利息总和
                    individualAccountParameter.setAae875(convertNullToBigDecimal(convertNullToBigDecimal(individual.getAae875()))); //number(16,2), 本年补缴历年本金,
                    individualAccountParameter.setAae876(convertNullToBigDecimal(convertNullToBigDecimal(individual.getAae876()))); //number(16,2), 本年补缴历年利息,
                    individualAccountParameter.setAaa031(convertNullToBigDecimal(individual.getCurrent_aaa031())); //number(5,4), 利率,

                    aae238_temp = aae238_temp.add(convertNullToBigDecimal(individual.getAae262())).add(convertNullToBigDecimal(individual.getAae264())).add(convertNullToBigDecimal(individual.getAae855()));
                    aae239_temp = aae239_temp.add(convertNullToBigDecimal(individual.getAae259())).add(convertNullToBigDecimal(individual.getAae263())).add(convertNullToBigDecimal(individual.getAae260())).add(convertNullToBigDecimal(individual.getAae265())).add(convertNullToBigDecimal(individual.getAae854())).add(convertNullToBigDecimal(individual.getAae856()));
                    aae240_temp = aae240_temp.add(convertNullToBigDecimal(individualAccountParameter.getAae850())).add(convertNullToBigDecimal(individualAccountParameter.getAae852())).add(convertNullToBigDecimal(individualAccountParameter.getAae857()));
                    aae238s.add(aae238_temp);
                    aae239s.add(aae239_temp);
                    individualAccountParameter.setAac001(aac001);
                    individualAccountParameter.setAaz159(aaz159);
                    individualAccountParameter.setAaa119(aaa119);
                    individualAccountParameter.setAaa513(aaa513);
                    individualAccountParameter.setAaz116(aaz116);
                    individualAccountParameter.setAaz117("");
                    individualAccountParameter.setAae825(aae825);
                    individualAccountParameter.setAae001(individual.getAae001());
                    individualAccountParameter.setAae013("正常账户计息");
                    individualAccountParameter.setAaz673(aaz116AndAaz673Map.get(aaz116));

                    individualAccountParameter.setAic376(this.aic376);
                    individualAccountParameter.setAae100(Constant.AAE100_1_YX);
                    individualAccountParameter.setActualPaymentMonths(individual.getActualPaymentMonths());
                    IndividualAccountParameters.add(individualAccountParameter);
                    normalIndividuals.add(individualAccountParameter);
                });

            } else {
                //正常缴费明细删除完，需要删除ac51
                Map deleteMap = new HashMap();
                deleteMap.put("aaz116", aaz116);
//                List<Map> zc_ac51s = NationalQueryRegister.einpCollectionQueryService().getAC51(deleteMap);
                List<Map> zc_ac51s = new ArrayList<>();
                Integer deleteAae001 = 1990;
                if (ValidateUtil.isNotEmpty(zc_ac51s)) {
                    String sdeleteAae001 = zc_ac51s.stream().min(Comparator.comparing(m -> Integer.parseInt(m.get("aae001").toString())))
                            .orElseGet(MyMap::new).get("aae001").toString();
                    deleteAae001 = Integer.parseInt(sdeleteAae001);
                }
                deleteMap.clear();
                deleteMap.put(aaz116, deleteAae001);
                deleteAaz116s.add(deleteMap);
            }

            IndividualAccount individualAccount = new IndividualAccount();
            individualAccount.setAaz116(aaz116);
            individualAccount.setAac001(aac001);
            individualAccount.setAaa119(aaa119);
            individualAccount.setAac062(aac062);
            individualAccount.setAaa513(aaa513);
            individualAccount.setAae206(aae206);
            individualAccount.setAic376(this.aic376);
            if (ValidateUtil.isNotEmpty(aae238s)) {
                aae238 = aae238s.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
            }
            individualAccount.setAae238(aae238);
            if (ValidateUtil.isNotEmpty(aae239s)) {
                aae239 = aae239s.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
            }
            individualAccount.setAae239(aae239);
            aae240 = aae239.add(aae238);
            individualAccount.setAae240(aae240);
            individualAccount.setAae100(Constant.AAE100_1_YX);
            individualAccount.setAaz159(aaz159);
            individualAccount.setAae013("正常账户计息");
            individualAccount.setAaz673(aaz116AndAaz673Map.get(aaz116));
            individualAccount.setAae368(Constant.AAE368_0_F);
            this.IndividualAccounts.add(individualAccount);
        }
    }


    /**
     * @param aaz116 aaz116
     * @param aae206 aae206
     * @Description 计算转移账户
     * @Author jzy
     * @Date 2022/01/03
     */
    protected void calculateTransferAccount(String aaz116, String aaa119, String aac062, String aaa513, Integer aae206) {
        Map<Integer, IndividualAccounttoCalculateParameter> individualAccounttoCalculateMaps = new HashMap();
        final BigDecimal[] aae238_kj = {BigDecimal.ZERO};
        final BigDecimal[] aae239_kj = {BigDecimal.ZERO};
        //BigDecimal aae240_kj = BigDecimal.ZERO;
        if (ValidateUtil.isNotEmpty(alltransferRefundAc08List) && zykjc == 0) {//没有收入明细
            Integer maxEndaae001 = aae206 / 100;
            zykjc = zykjc + 1;
            //转移当年如果存在退费，因为原本取明细，转移当年的退费明细没有包含，然后往后年度结息 又会多扣了转移当年的退费本金，这个是不合理的，本次修改 退费只取转移当年之前的作为负台账生成 之后的转移账户自动计息
            List<MyMap> transferRefundAc08 = ListUtil.mapList2MyMapList(alltransferRefundAc08List.stream().filter(m -> Integer.parseInt(m.get("aae003").toString().substring(0, 4)) < maxEndaae001).collect(Collectors.toList()));
            //更据获取的正常缴费明细进行计息
            if (ValidateUtil.isNotEmpty(transferRefundAc08)) {
                Integer minAae003 = transferRefundAc08.stream().min(Comparator.comparing(myMap -> myMap.getAsInteger("aae003"))).orElse(new MyMap()).getAsInteger("aae003");
                incomeDeadline = transferRefundAc08.stream().max(Comparator.comparing(myMap -> myMap.getAsInteger("aae003"))).orElse(new MyMap()).getAsInteger("aae003");
                //从此开始计息
                Integer returnBeginAae001 = getBusinessYear(minAae003);
                Integer endAae001;
                if (null != this.aae042) {
                    endAae001 = getBusinessYear(this.aae042);
                } else {
                    endAae001 = nowaae001;
                }
                //获取到账日期的最大年度
                Integer incomeDeadlineYear = getBusinessYear(incomeDeadline);
                if (incomeDeadlineYear < endAae001) {
                    incomeDeadlineYear = endAae001;
                }
                if (incomeDeadlineYear.intValue() < nowaae001.intValue()) {
                    incomeDeadlineYear = nowaae001;
                }

                Integer year = returnBeginAae001;
                BigDecimal aae875 = BigDecimal.ZERO; //本年补缴历年本金
                BigDecimal aae876 = BigDecimal.ZERO; //本年补缴历年利息

                BigDecimal aae849 = BigDecimal.ZERO;//截至上年末个人账户单位缴费部分划转累计本息
                BigDecimal aae851 = BigDecimal.ZERO;//截至上年末个人账户个人缴费部分划转累计本息
                List<IndividualAccounttoCalculateParameter> individualAccounttoCalculateParameters = new ArrayList();

                IndividualAccounttoCalculateParameter lastIndividualAccounttoCalculateParameter = new IndividualAccounttoCalculateParameter();
                while (year <= incomeDeadlineYear) {

                    IndividualAccounttoCalculateParameter individualAccounttoCalculateParameter = new IndividualAccounttoCalculateParameter();
                    if (null != lastIndividualAccounttoCalculateParameter) {//截止上年末不为空，赋值截止上年末
                        aae849 = convertNullToBigDecimal(lastIndividualAccounttoCalculateParameter.getAae849());
                        aae851 = convertNullToBigDecimal(lastIndividualAccounttoCalculateParameter.getAae851());
                        aae849 = aae849.add(convertNullToBigDecimal(lastIndividualAccounttoCalculateParameter.getAae262())).add(convertNullToBigDecimal(lastIndividualAccounttoCalculateParameter.getAae263())).add(convertNullToBigDecimal(lastIndividualAccounttoCalculateParameter.getAae259()));
                        aae851 = aae851.add(convertNullToBigDecimal(lastIndividualAccounttoCalculateParameter.getAae264())).add(convertNullToBigDecimal(lastIndividualAccounttoCalculateParameter.getAae265())).add(convertNullToBigDecimal(lastIndividualAccounttoCalculateParameter.getAae260()));
                    }
                    //取出业务年度
                    List<AnnualConversionTransverse> annualConversions = businessAae001Map.get(year);
                    Integer aae041;//开始年月
                    Integer aae042;//结束年月
                    BigDecimal bae084;//年度月数
                    if (nowaae001.intValue() <= year.intValue()) {//大于当前年度的数据，全部累加在本年度（对于一次性养老缴费导致的账户后移动）
                        if (ValidateUtil.isNotEmpty(annualConversions)) {
                            aae041 = annualConversions.get(0).getAae041();
                            aae042 = 999999;
                            bae084 = annualConversions.get(0).getBae084();
                        } else {
                            aae041 = Integer.parseInt(year + "01");
                            aae042 = 999999;
                            bae084 = BigDecimal.valueOf(12);
                        }
                    } else {
                        if (ValidateUtil.isNotEmpty(annualConversions)) {
                            aae041 = annualConversions.get(0).getAae041();
                            aae042 = annualConversions.get(0).getAae042();
                            bae084 = annualConversions.get(0).getBae084();
                        } else {
                            aae041 = Integer.parseInt(year + "01");
                            aae042 = Integer.parseInt(year + "12");
                            bae084 = BigDecimal.valueOf(12);
                        }
                    }
                    List<MyMap> nowAccountList;
                    if (Constant.AAE140_120_JGSYDWGZRYJBYLBX.equals(aae140)) {//机关养老扣减按照经办当年显示
                        nowAccountList = transferRefundAc08.stream().filter(myMap -> (myMap.getAsInteger("aae003")) >= aae041
                                && aae042 >= (myMap.getAsInteger("aae003")) && (myMap.getAsString("aae793").equals(Constant.AAE793_1061_ZR)
                                || myMap.getAsString("aae793").equals(Constant.AAE793_1062_JGZR)
                                || myMap.getAsString("aae793").equals(Constant.AAE793_1064_JRZR))).collect(Collectors.toList());
                    } else {
//                        nowAccountList = transferRefundAc08.stream().filter(myMap -> (myMap.getAsInteger("aab191")/100 ) >= aae041
//                                && aae042 >= (myMap.getAsInteger("aab191") / 100) && (myMap.getAsString("aae793").equals(Constant.AAE793_1061_ZR)
//                                || myMap.getAsString("aae793").equals(Constant.AAE793_1062_JGZR)
//                                || myMap.getAsString("aae793").equals(Constant.AAE793_1064_JRZR))).collect(Collectors.toList());

                        nowAccountList = transferRefundAc08.stream().filter(myMap -> (myMap.getAsInteger("aae003")) >= aae041
                                && aae042 >= (myMap.getAsInteger("aae003")) && (myMap.getAsString("aae793").equals(Constant.AAE793_1061_ZR)
                                || myMap.getAsString("aae793").equals(Constant.AAE793_1062_JGZR)
                                || myMap.getAsString("aae793").equals(Constant.AAE793_1064_JRZR))).collect(Collectors.toList());
                    }

                    Integer aae202 = 0;//实缴月数
                    List<MyMap> nowAccountList_aae202;
                    /*if (Constant.AAE140_120_JGSYDWGZRYJBYLBX.equals(aae140)) {//机关养老扣减按照经办当年显示
                        nowAccountList_aae202 = transferRefundAc08.stream().filter(myMap -> myMap.getAsInteger("aae003")  >= aae041
                                && aae042 >= myMap.getAsInteger("aae003") ).collect(Collectors.toList());
                    }else{
                        nowAccountList_aae202 = transferRefundAc08.stream().filter(myMap -> myMap.getAsInteger("aae003") >= aae041
                                && aae042 >= myMap.getAsInteger("aae003") ).collect(Collectors.toList());
                    }*/
                    nowAccountList_aae202 = transferRefundAc08.stream().filter(myMap -> myMap.getAsInteger("aae003") >= aae041
                            && aae042 >= myMap.getAsInteger("aae003")).collect(Collectors.toList());

                    if (ValidateUtil.isNotEmpty(nowAccountList_aae202)) {
                        for (MyMap myMap : nowAccountList_aae202) {
                            aae202 = aae202 + myMap.getAsInteger("aae202");
                        }
                    }

                    BigDecimal nowAae081 = BigDecimal.ZERO;
                    BigDecimal nowAae083 = BigDecimal.ZERO;
                    BigDecimal nowAae789 = BigDecimal.ZERO;
                    BigDecimal nowAae791 = BigDecimal.ZERO;
                    List<MyMap> overYears_aae262S_spends_list = new ArrayList(); //本年单位缴费部分划入个人账户本金划转历年集合
                    List<MyMap> overYears_aae264S_spends_list = new ArrayList(); //本年个人缴费部分划入个人账户本金划转历年集合
                    if (ValidateUtil.isNotEmpty(nowAccountList)) {
                        for (MyMap myMap : nowAccountList) {
                            BigDecimal aae081 = myMap.getAsBigDecimalNullToZero("aae081"); //单位实缴划入个人账户金额
                            BigDecimal aae083 = myMap.getAsBigDecimalNullToZero("aae083"); //个人实缴划入个人账户金额
                            BigDecimal aae789 = myMap.getAsBigDecimalNullToZero("aae789"); //单位实缴划入个人账户金额利息
                            BigDecimal aae791 = myMap.getAsBigDecimalNullToZero("aae791"); //个人实缴划入个人账户金额利息
                            nowAae081 = nowAae081.add(aae081);//单位实缴划入个人账户金额
                            nowAae789 = nowAae789.add(aae789);//单位实缴划入个人账户金额利息
                            nowAae083 = nowAae083.add(aae083);//个人实缴划入个人账户金额+个人实缴划入个人账户金额利息
                            nowAae791 = nowAae791.add(aae791);
                            //单位当年实缴金额,个人当年实缴金额,其他当年实缴金额,当年单位划转其他年度金额,当年个人划转其他年度金额,当年其他划转其他年度金额,当年利率,历年利率,单位历年实缴金额,个人历年实缴金额,其他历年实缴金额,历年单位划转其他年度金额,历年个人划转其他年度金额,历年其他划转其他年度金额
                        }
                    } else {
                        nowAae081 = BigDecimal.ZERO;
                        nowAae083 = BigDecimal.ZERO;
                    }
                    //当年利率
                    List<InterestRate> currentInterestRates = toYearsCurrentInterestRate.get(year);
                    BigDecimal current_aaa031; // 当年利率
                    BigDecimal overYears_aaa031; // 历年利率
                    if (year.intValue() < endAae001 || year.intValue() > endAae001) {//如果不是计息截止日期，就取利率同年开始日期最大的那条
                        List<InterestRate> aaa031s = currentInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                        if (ValidateUtil.isNotEmpty(aaa031s)) {
                            current_aaa031 = aaa031s.get(0).getAaa031();
                        } else {
                            current_aaa031 = BigDecimal.ZERO;
                        }
                    } else {//大于计息截止日期
                        currentInterestRates = toYearsCurrentInterestRate.get(endAae001);
                        if (ValidateUtil.isNotEmpty(currentInterestRates)) {
                            List<InterestRate> aaa031s = currentInterestRates.stream().filter(interestRate -> interestRate.getAae041() <= this.aae042 && this.aae042 <= interestRate.getAae042()).collect(Collectors.toList());
                            if (ValidateUtil.isNotEmpty(aaa031s)) {
                                current_aaa031 = aaa031s.get(0).getAaa031();
                            } else {
                                current_aaa031 = BigDecimal.ZERO;
                            }
                        } else {
                            current_aaa031 = BigDecimal.ZERO;
                        }
                    }
                    //历年利率
                    List<InterestRate> overInterestRates = toYearsOverInterestRate.get(year);
                    if (year.intValue() < endAae001 || year.intValue() > endAae001) {
                        List<InterestRate> aaa031s = overInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                        if (ValidateUtil.isNotEmpty(aaa031s)) {
                            overYears_aaa031 = aaa031s.get(0).getAaa031();
                        } else {
                            overYears_aaa031 = BigDecimal.ZERO;
                        }
                    } else {
                        overInterestRates = toYearsOverInterestRate.get(endAae001);
                        if (ValidateUtil.isNotEmpty(overInterestRates)) {
                            List<InterestRate> aaa031s = overInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                            if (ValidateUtil.isNotEmpty(aaa031s)) {
                                overYears_aaa031 = aaa031s.get(0).getAaa031();
                            } else {
                                overYears_aaa031 = BigDecimal.ZERO;
                            }
                        } else {
                            overYears_aaa031 = BigDecimal.ZERO;
                        }
                    }
                    //计算利息
                    //历年利息（2006前:本金*利率*年度月数/12;2006后:本金*利率;最后截止年月，是本金*利率*所占月数/12）
                    BigDecimal aae259 = BigDecimal.ZERO;// 截至上年末个人账户单位缴费部分划转本息在本年产生的利息,
                    BigDecimal aae260 = BigDecimal.ZERO;// 截至上年末个人账户个人缴费部分划转本息在本年产生的利息
//                        aae259 = AccountCalculatInter.calculatPastYearInter(aae849, overYears_aaa031, bae084, year, this.aae042, endAae001);
//                        aae260 = AccountCalculatInter.calculatPastYearInter(aae851, overYears_aaa031, bae084, year, this.aae042, endAae001);
                    //本年单位缴费部分划入个人账户本金所产生的利息
                    BigDecimal aae263 = BigDecimal.ZERO;
                    BigDecimal aae265 = BigDecimal.ZERO;
                    //当年利息（2006前:本金*利率*实缴/12/2;2006后:本金*利率*1.083/2）
//                        aae263 = AccountCalculatInter.calculatThisYearInter(nowAae081, current_aaa031, aae202, year, endAae001);
//                        aae265 = AccountCalculatInter.calculatThisYearInter(nowAae083, current_aaa031, aae202, year, endAae001);
                    aae263 = aae263.add(nowAae789);
                    aae265 = aae265.add(nowAae791);
                    //截止上年末本息=本年收入+本年利息+历年利息
                    individualAccounttoCalculateParameter.setAae001(year);
                    individualAccounttoCalculateParameter.setActualPaymentMonths(aae202);
                    individualAccounttoCalculateParameter.setAae849(aae849);
                    individualAccounttoCalculateParameter.setAae851(aae851);
                    individualAccounttoCalculateParameter.setAae259(aae259);
                    individualAccounttoCalculateParameter.setAae260(aae260);


                    individualAccounttoCalculateParameter.setAae262(nowAae081);
                    individualAccounttoCalculateParameter.setAae263(aae263);
                    individualAccounttoCalculateParameter.setAae264(nowAae083);
                    individualAccounttoCalculateParameter.setAae265(aae265);
                    individualAccounttoCalculateParameter.setCurrent_aaa031(current_aaa031);
                    individualAccounttoCalculateParameter.setOverYears_aaa031(overYears_aaa031);
                    individualAccounttoCalculateParameter.setOverYears_aae262S_spends(overYears_aae262S_spends_list);
                    individualAccounttoCalculateParameter.setOverYears_aae264S_spends(overYears_aae264S_spends_list);
                    individualAccounttoCalculateParameter.setAae876(aae876);
                    individualAccounttoCalculateParameter.setAae875(aae875);
                    individualAccounttoCalculateMaps.put(year, individualAccounttoCalculateParameter);
                    year = year + 1;
                    BeanUtils.copyProperties(individualAccounttoCalculateParameter, lastIndividualAccounttoCalculateParameter);
                }
            }
            List<IndividualAccounttoCalculateParameter> individualAccounttoCalculateParameters = new ArrayList();
            individualAccounttoCalculateMaps.forEach((key, indi) -> {
                individualAccounttoCalculateParameters.add(indi);
            });


            individualAccounttoCalculateParameters.stream().sorted(Comparator.comparing(ind -> ind.getAae001()));
            individualAccounttoCalculateParameters.stream().forEach(individual -> {
                BigDecimal aae238_temp = BigDecimal.ZERO;
                BigDecimal aae239_temp = BigDecimal.ZERO;
                BigDecimal aae240_temp = BigDecimal.ZERO;

                IndividualAccountParameter individualAccountParameter = new IndividualAccountParameter();

                //因为转移当年会自动重汇台账，所以不需要重复在退一遍
                //Integer maxEndaae001 = Integer.parseInt(DateUtil.date2Str(DateUtil.getCurDate(), "yyyy"));
                // Integer maxEndaae001 = aae206 / 100;
                //   if (individual.getAae001() >= maxEndaae001) {

//                    individualAccountParameter.setAae849(convertNullToBigDecimal(individual.getAae849()).negate()); //number(16,2), 截至上年末个人账户单位缴费部分划转累计本息,
//                    individualAccountParameter.setAae259(convertNullToBigDecimal(individual.getAae259()).negate()); //number(16,2), 截至上年末个人账户单位缴费部分划转本息在本年产生的利息,
//                    individualAccountParameter.setAae262(convertNullToBigDecimal(BigDecimal.ZERO)); //number(16,2), 本年单位缴费部分划入个人账户本金,
//                    individualAccountParameter.setAae263(convertNullToBigDecimal(individual.getAae263()).negate()); //number(16,2), 本年单位缴费部分划入个人账户本金所产生的利息,
//                    individualAccountParameter.setAae850(convertNullToBigDecimal((individual.getAae849()).add(convertNullToBigDecimal(individual.getAae259())).add(BigDecimal.ZERO).add(convertNullToBigDecimal(individual.getAae263()))).negate()); //number(16,2), 截至本年末个人账户单位缴费部分划转累计本息,
//                    individualAccountParameter.setAae851(convertNullToBigDecimal(individual.getAae851()).negate()); //number(16,2), 截至上年末个人账户个人缴费部分划转累计本息,
//                    individualAccountParameter.setAae260(convertNullToBigDecimal(individual.getAae260()).negate()); //number(16,2), 截至上年末个人账户个人缴费部分划转本息在本年产生的利息,
//                    individualAccountParameter.setAae264(convertNullToBigDecimal(BigDecimal.ZERO)); //number(16,2), 本年个人缴费部分划入个人账户本金,
//                    individualAccountParameter.setAae265(convertNullToBigDecimal(individual.getAae265()).negate()); //number(16,2), 本年个人缴费部分划入个人账户本金所产生的利息,
//                    individualAccountParameter.setAae852(convertNullToBigDecimal(individual.getAae851()).add(convertNullToBigDecimal(individual.getAae260())).add(convertNullToBigDecimal(BigDecimal.ZERO)).add(convertNullToBigDecimal(individual.getAae265())).negate()); //number(16,2), 截至本年末个人账户个人缴费部分划转累计本息,
//                    individualAccountParameter.setAae853(convertNullToBigDecimal(individual.getAae853()).negate()); //number(16,2), 截至上年末个人账户其他部分划转累计本息,
//                    individualAccountParameter.setAae854(convertNullToBigDecimal(individual.getAae854()).negate()); //number(16,2), 截至上年末个人账户其他部分划转本息在本年产生的利息,
//                    individualAccountParameter.setAae855(convertNullToBigDecimal(individual.getAae855()).negate()); //number(16,2), 本年其他部分划入个人账户本金,
//                    individualAccountParameter.setAae856(convertNullToBigDecimal(individual.getAae856()).negate()); //number(16,2), 本年其他部分划入个人账户本金所产生的利息,
//                    individualAccountParameter.setAae857(convertNullToBigDecimal(individual.getAae853()).add(convertNullToBigDecimal(individual.getAae854())).add(convertNullToBigDecimal(individual.getAae855())).add(convertNullToBigDecimal(individual.getAae856())).negate()); //number(16,2), 截至本年末个人账户其他部分划转累计本息,
//                    individualAccountParameter.setAae873(BigDecimal.ZERO); //number(16,2), 本年本金总和,
//                    individualAccountParameter.setAae874(convertNullToBigDecimal(individual.getAae259()).add(convertNullToBigDecimal(individual.getAae263()).add(convertNullToBigDecimal(individual.getAae260())).add(convertNullToBigDecimal(individual.getAae265())).add(convertNullToBigDecimal(individual.getAae854())).add(convertNullToBigDecimal(individual.getAae856()))).negate());//本年利息总和
//                    individualAccountParameter.setAae875(convertNullToBigDecimal(convertNullToBigDecimal(individual.getAae875())).negate()); //number(16,2), 本年补缴历年本金,
//                    individualAccountParameter.setAae876(convertNullToBigDecimal(convertNullToBigDecimal(individual.getAae876())).negate()); //number(16,2), 本年补缴历年利息,
//                    individualAccountParameter.setAaa031(convertNullToBigDecimal(individual.getCurrent_aaa031())); //number(5,4), 利率,
//
//                    aae238_temp = aae238_temp.add(convertNullToBigDecimal(individual.getAae855()).negate());
//                    aae239_temp = aae239_temp.add(convertNullToBigDecimal(individual.getAae259())).add(convertNullToBigDecimal(individual.getAae263())).add(convertNullToBigDecimal(individual.getAae260())).add(convertNullToBigDecimal(individual.getAae265())).add(convertNullToBigDecimal(individual.getAae854())).add(convertNullToBigDecimal(individual.getAae856()).negate());
//                    aae240_temp = aae240_temp.add(convertNullToBigDecimal(individualAccountParameter.getAae850())).add(convertNullToBigDecimal(individualAccountParameter.getAae852())).add(convertNullToBigDecimal(individualAccountParameter.getAae857()).negate());

                //     } else {

                individualAccountParameter.setAae849(convertNullToBigDecimal(individual.getAae849()).negate()); //number(16,2), 截至上年末个人账户单位缴费部分划转累计本息,
                individualAccountParameter.setAae259(convertNullToBigDecimal(individual.getAae259()).negate()); //number(16,2), 截至上年末个人账户单位缴费部分划转本息在本年产生的利息,
                individualAccountParameter.setAae262(convertNullToBigDecimal(individual.getAae262()).negate()); //number(16,2), 本年单位缴费部分划入个人账户本金,
                individualAccountParameter.setAae263(convertNullToBigDecimal(individual.getAae263()).negate()); //number(16,2), 本年单位缴费部分划入个人账户本金所产生的利息,
                individualAccountParameter.setAae850(convertNullToBigDecimal((individual.getAae849()).add(convertNullToBigDecimal(individual.getAae259())).add(convertNullToBigDecimal(individual.getAae262())).add(convertNullToBigDecimal(individual.getAae263()))).negate()); //number(16,2), 截至本年末个人账户单位缴费部分划转累计本息,
                individualAccountParameter.setAae851(convertNullToBigDecimal(individual.getAae851()).negate()); //number(16,2), 截至上年末个人账户个人缴费部分划转累计本息,
                individualAccountParameter.setAae260(convertNullToBigDecimal(individual.getAae260()).negate()); //number(16,2), 截至上年末个人账户个人缴费部分划转本息在本年产生的利息,
                individualAccountParameter.setAae264(convertNullToBigDecimal(individual.getAae264()).negate()); //number(16,2), 本年个人缴费部分划入个人账户本金,
                individualAccountParameter.setAae265(convertNullToBigDecimal(individual.getAae265()).negate()); //number(16,2), 本年个人缴费部分划入个人账户本金所产生的利息,
                individualAccountParameter.setAae852(convertNullToBigDecimal(individual.getAae851()).add(convertNullToBigDecimal(individual.getAae260())).add(convertNullToBigDecimal(individual.getAae264())).add(convertNullToBigDecimal(individual.getAae265())).negate()); //number(16,2), 截至本年末个人账户个人缴费部分划转累计本息,
                individualAccountParameter.setAae853(convertNullToBigDecimal(individual.getAae853()).negate()); //number(16,2), 截至上年末个人账户其他部分划转累计本息,
                individualAccountParameter.setAae854(convertNullToBigDecimal(individual.getAae854()).negate()); //number(16,2), 截至上年末个人账户其他部分划转本息在本年产生的利息,
                individualAccountParameter.setAae855(convertNullToBigDecimal(individual.getAae855()).negate()); //number(16,2), 本年其他部分划入个人账户本金,
                individualAccountParameter.setAae856(convertNullToBigDecimal(individual.getAae856()).negate()); //number(16,2), 本年其他部分划入个人账户本金所产生的利息,
                individualAccountParameter.setAae857(convertNullToBigDecimal(individual.getAae853()).add(convertNullToBigDecimal(individual.getAae854())).add(convertNullToBigDecimal(individual.getAae855())).add(convertNullToBigDecimal(individual.getAae856())).negate()); //number(16,2), 截至本年末个人账户其他部分划转累计本息,
                individualAccountParameter.setAae873(convertNullToBigDecimal(individual.getAae262()).add(convertNullToBigDecimal(individual.getAae264())).negate()); //number(16,2), 本年本金总和,
                individualAccountParameter.setAae874(convertNullToBigDecimal(individual.getAae259()).add(convertNullToBigDecimal(individual.getAae263()).add(convertNullToBigDecimal(individual.getAae260())).add(convertNullToBigDecimal(individual.getAae265())).add(convertNullToBigDecimal(individual.getAae854())).add(convertNullToBigDecimal(individual.getAae856()))).negate());//本年利息总和
                individualAccountParameter.setAae875(convertNullToBigDecimal(convertNullToBigDecimal(individual.getAae875())).negate()); //number(16,2), 本年补缴历年本金,
                individualAccountParameter.setAae876(convertNullToBigDecimal(convertNullToBigDecimal(individual.getAae876())).negate()); //number(16,2), 本年补缴历年利息,
                individualAccountParameter.setAaa031(convertNullToBigDecimal(individual.getCurrent_aaa031())); //number(5,4), 利率,

                aae238_temp = aae238_temp.add(convertNullToBigDecimal(individual.getAae262())).add(convertNullToBigDecimal(individual.getAae264())).add(convertNullToBigDecimal(individual.getAae855()).negate());
                aae239_temp = aae239_temp.add(convertNullToBigDecimal(individual.getAae259())).add(convertNullToBigDecimal(individual.getAae263())).add(convertNullToBigDecimal(individual.getAae260())).add(convertNullToBigDecimal(individual.getAae265())).add(convertNullToBigDecimal(individual.getAae854())).add(convertNullToBigDecimal(individual.getAae856()).negate());
                aae240_temp = aae240_temp.add(convertNullToBigDecimal(individualAccountParameter.getAae850())).add(convertNullToBigDecimal(individualAccountParameter.getAae852())).add(convertNullToBigDecimal(individualAccountParameter.getAae857()).negate());
                //}

                aae238_kj[0] = aae238_kj[0].add(aae238_temp);
                aae239_kj[0] = aae239_kj[0].add(aae239_temp);

                individualAccountParameter.setAac001(aac001);
                individualAccountParameter.setAaz159(aaz159);
                individualAccountParameter.setAaa119(aaa119);
                individualAccountParameter.setAaa513(aaa513);
                individualAccountParameter.setAaz116(aaz116);
                individualAccountParameter.setAaz117("");
                individualAccountParameter.setAae825(Constant.AAE825_0_F);
                individualAccountParameter.setAae001(individual.getAae001());
                individualAccountParameter.setAae013("转移账户退费冲销账户计息");


                individualAccountParameter.setAic376(this.aic376);
                individualAccountParameter.setAae100(Constant.AAE100_1_YX);
                individualAccountParameter.setActualPaymentMonths(individual.getActualPaymentMonths());

                IndividualAccountParameters.add(individualAccountParameter);

            });
        }

        List<Map> transferAccountAc51s = new ArrayList<>();
        List<Map> allTransferAccountAc51s = new ArrayList<>();
        Map queryMap = new HashMap();
        queryMap.put("aaz116", aaz116);

        if (ValidateUtil.isNotEmpty(alltransferRefundAc08List)) {
            allTransferAccountAc51s = new ArrayList<>();
//            allTransferAccountAc51s = NationalQueryRegister.einpCollectionQueryService().getAC51(queryMap);
            List<MyMap> allTransferMyMapAccountAc51s = ListUtil.mapList2MyMapList(allTransferAccountAc51s);
            List<MyMap> deleteList = allTransferMyMapAccountAc51s.stream().filter(mm -> (mm.getAsBigDecimalNullToZero("aae849")
                    .add(mm.getAsBigDecimalNullToZero("aae262"))
                    .add(mm.getAsBigDecimalNullToZero("aae851"))
                    .add(mm.getAsBigDecimalNullToZero("aae264"))
                    .add(mm.getAsBigDecimalNullToZero("aae853"))
                    .add(mm.getAsBigDecimalNullToZero("aae855"))).compareTo(BigDecimal.ZERO) < 0).collect(Collectors.toList());
            deleteAaz117s.addAll(deleteList);

            List<MyMap> deleteListZero = allTransferMyMapAccountAc51s.stream().filter(mm -> (mm.getAsBigDecimalNullToZero("aae849")
                    .add(mm.getAsBigDecimalNullToZero("aae262"))
                    .add(mm.getAsBigDecimalNullToZero("aae851"))
                    .add(mm.getAsBigDecimalNullToZero("aae264"))
                    .add(mm.getAsBigDecimalNullToZero("aae853"))
                    .add(mm.getAsBigDecimalNullToZero("aae855"))).compareTo(BigDecimal.ZERO) == 0
                    && "转移账户退费冲销账户计息".equals(mm.getAsString("aae013"))).collect(Collectors.toList());
            deleteAaz117s.addAll(deleteListZero);

            transferAccountAc51s = allTransferMyMapAccountAc51s.stream().filter(mm -> (mm.getAsBigDecimalNullToZero("aae849")
                    .add(mm.getAsBigDecimalNullToZero("aae262"))
                    .add(mm.getAsBigDecimalNullToZero("aae851"))
                    .add(mm.getAsBigDecimalNullToZero("aae264"))
                    .add(mm.getAsBigDecimalNullToZero("aae853"))
                    .add(mm.getAsBigDecimalNullToZero("aae855"))).compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
        } else {
//            allTransferAccountAc51s = NationalQueryRegister.einpCollectionQueryService().getAC51(queryMap);
            allTransferAccountAc51s = new ArrayList<>();
            List<MyMap> allTransferMyMapAccountAc51s = ListUtil.mapList2MyMapList(allTransferAccountAc51s);
            List<MyMap> deleteList = allTransferMyMapAccountAc51s.stream().filter(mm -> (mm.getAsBigDecimalNullToZero("aae849")
                    .add(mm.getAsBigDecimalNullToZero("aae262"))
                    .add(mm.getAsBigDecimalNullToZero("aae851"))
                    .add(mm.getAsBigDecimalNullToZero("aae264"))
                    .add(mm.getAsBigDecimalNullToZero("aae853"))
                    .add(mm.getAsBigDecimalNullToZero("aae855"))).compareTo(BigDecimal.ZERO) < 0).collect(Collectors.toList());
            deleteAaz117s.addAll(deleteList);
            List<MyMap> deleteListZero = allTransferMyMapAccountAc51s.stream().filter(mm -> (mm.getAsBigDecimalNullToZero("aae849")
                    .add(mm.getAsBigDecimalNullToZero("aae262"))
                    .add(mm.getAsBigDecimalNullToZero("aae851"))
                    .add(mm.getAsBigDecimalNullToZero("aae264"))
                    .add(mm.getAsBigDecimalNullToZero("aae853"))
                    .add(mm.getAsBigDecimalNullToZero("aae855"))).compareTo(BigDecimal.ZERO) == 0
                    && "转移账户退费冲销账户计息".equals(mm.getAsString("aae013"))
            ).collect(Collectors.toList());
            deleteAaz117s.addAll(deleteListZero);


            if (ValidateUtil.isNotEmpty(deleteList)) {
                transferAccountAc51s = allTransferMyMapAccountAc51s.stream().filter(mm -> (mm.getAsBigDecimalNullToZero("aae849")
                        .add(mm.getAsBigDecimalNullToZero("aae262"))
                        .add(mm.getAsBigDecimalNullToZero("aae851"))
                        .add(mm.getAsBigDecimalNullToZero("aae264"))
                        .add(mm.getAsBigDecimalNullToZero("aae853"))
                        .add(mm.getAsBigDecimalNullToZero("aae855"))).compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
            } else {
//                transferAccountAc51s = NationalQueryRegister.einpCollectionQueryService().getAC51(queryMap);
                transferAccountAc51s = new ArrayList<>();
            }
        }
        Integer beginAae001 = getBusinessYear(aae206);
        Integer startAae001 = beginAae001;
        List<MyMap> allAc08MapList = ListUtil.mapList2MyMapList(allAc08List);
        List<String> zy_aae793s = Arrays.asList(Constant.AAE793_1061_ZR, Constant.AAE793_1062_JGZR, Constant.AAE793_1063_CXZR, Constant.AAE793_1064_JRZR);
        List<Map> transferAc08s = allAc08MapList.stream().filter(myMap -> Constant.AAA115_10_ZCYJ.equals(myMap.getAsString("aaa115")) && zy_aae793s.contains(myMap.getAsString("aae793")) && aaz116.equals("".equals(myMap.getAsString("aae819")) ? aaz116 : myMap.getAsString("aae819"))).collect(Collectors.toList());
        if (ValidateUtil.isEmpty(transferAc08s)) {//没有收入明细从下一年开始计息
//            startAae001 = beginAae001 + 1;
            startAae001 = beginAae001;
        }

        Integer jxAae001 = getBusinessYear(aae206);
        BigDecimal aae238 = BigDecimal.ZERO;
        BigDecimal aae239 = BigDecimal.ZERO;
        BigDecimal aae240 = BigDecimal.ZERO;
        List<IndividualAccountParameter> zyhzList = new ArrayList<>();

        if (ValidateUtil.isNotEmpty(transferAccountAc51s)) {
            List<MyMap> transferMyMapAccountAc51s = ListUtil.mapList2MyMapList(transferAccountAc51s);

            Integer finalStartAae00 = startAae001;
            List<MyMap> jsxqList = transferMyMapAccountAc51s.stream().filter(myMap -> myMap.getAsInteger("aae001") < finalStartAae00).collect(Collectors.toList());
            BigDecimal jzqAae849 = BigDecimal.ZERO;
            BigDecimal jzqAae851 = BigDecimal.ZERO;
            if (ValidateUtil.isNotEmpty(jsxqList)) {
                jzqAae849 = jsxqList.stream().min(Comparator.comparing(myMap -> myMap.getAsInteger("aae001"))).get().getAsBigDecimalNullToZero("aae849");
                jzqAae851 = jsxqList.stream().min(Comparator.comparing(myMap -> myMap.getAsInteger("aae001"))).get().getAsBigDecimalNullToZero("aae851");
            }
            if (ValidateUtil.isNotEmpty(jsxqList)) {
                BigDecimal aae262_jxq = jsxqList.stream().map(myMap -> myMap.getAsBigDecimalNullToZero("aae262")).reduce(BigDecimal.ZERO, BigDecimal::add);
                BigDecimal aae264_jxq = jsxqList.stream().map(myMap -> myMap.getAsBigDecimalNullToZero("aae264")).reduce(BigDecimal.ZERO, BigDecimal::add);
                BigDecimal aae855_jxq = jsxqList.stream().map(myMap -> myMap.getAsBigDecimalNullToZero("aae855")).reduce(BigDecimal.ZERO, BigDecimal::add);

                BigDecimal aae259_jxq = jsxqList.stream().map(myMap -> myMap.getAsBigDecimalNullToZero("aae259")).reduce(BigDecimal.ZERO, BigDecimal::add);
                BigDecimal aae263_jxq = jsxqList.stream().map(myMap -> myMap.getAsBigDecimalNullToZero("aae263")).reduce(BigDecimal.ZERO, BigDecimal::add);
                BigDecimal aae260_jxq = jsxqList.stream().map(myMap -> myMap.getAsBigDecimalNullToZero("aae260")).reduce(BigDecimal.ZERO, BigDecimal::add);
                BigDecimal aae265_jxq = jsxqList.stream().map(myMap -> myMap.getAsBigDecimalNullToZero("aae265")).reduce(BigDecimal.ZERO, BigDecimal::add);
                BigDecimal aae854_jxq = jsxqList.stream().map(myMap -> myMap.getAsBigDecimalNullToZero("aae854")).reduce(BigDecimal.ZERO, BigDecimal::add);
                BigDecimal aae856_jxq = jsxqList.stream().map(myMap -> myMap.getAsBigDecimalNullToZero("aae856")).reduce(BigDecimal.ZERO, BigDecimal::add);

                aae238 = aae238.add(aae262_jxq).add(aae264_jxq).add(aae855_jxq);
                aae239 = aae239.add(aae259_jxq).add(aae263_jxq).add(aae260_jxq).add(aae265_jxq).add(aae854_jxq).add(aae856_jxq);
            }
            aae238 = aae238.add(jzqAae849).add(jzqAae851);
            List<MyMap> transferAccountAc51sMyMps = ListUtil.list2MyMapList(transferAccountAc51s);
            //List<MyMap> transcheck = transferAccountAc51sMyMps.stream().filter(ml -> ml.getAsInteger("aae001").intValue() == beginAae001.intValue()).collect(Collectors.toList());
            Integer year = startAae001;

            Map deleteMap = new HashMap();
            deleteMap.put(aaz116, year);
            deleteAaz116s.add(deleteMap);
            Integer endAae001;
            if (!ValidateUtil.isEmpty(this.aae042)) {
                endAae001 = getBusinessYear(this.aae042);
            } else {
                endAae001 = nowaae001;
            }
            Integer incomeDeadlineYear = endAae001;
            if (incomeDeadlineYear.intValue() < nowaae001.intValue()) {
                incomeDeadlineYear = nowaae001;
            }
            int first_falg = 0;
            List<MyMap> overAllYearList = new ArrayList<>();
            Map<Integer, List<MyMap>> mapTransFers = transferMyMapAccountAc51s.stream().collect(Collectors.groupingBy(cc -> cc.getAsInteger("aae001")));
            while (year <= incomeDeadlineYear) {
                BigDecimal aae849; //截至上年末个人账户单位缴费部分划转累计本息,
                BigDecimal aae259; //截至上年末个人账户单位缴费部分划转本息在本年产生的利息,
                BigDecimal aae262 = BigDecimal.ZERO; //本年单位缴费部分划入个人账户本金,
                BigDecimal aae263 = BigDecimal.ZERO; //本年单位缴费部分划入个人账户本金所产生的利息,
                BigDecimal aae850 = BigDecimal.ZERO; //截至本年末个人账户单位缴费部分划转累计本息,
                BigDecimal aae851; //截至上年末个人账户个人缴费部分划转累计本息,
                BigDecimal aae260; //截至上年末个人账户个人缴费部分划转本息在本年产生的利息,
                BigDecimal aae264 = BigDecimal.ZERO; //本年个人缴费部分划入个人账户本金,
                BigDecimal aae265 = BigDecimal.ZERO; //本年个人缴费部分划入个人账户本金所产生的利息,
                BigDecimal aae852 = BigDecimal.ZERO; //截至本年末个人账户个人缴费部分划转累计本息,
                BigDecimal aae853; //截至上年末个人账户其他部分划转累计本息,
                BigDecimal aae854; //截至上年末个人账户其他部分划转本息在本年产生的利息,
                BigDecimal aae855 = BigDecimal.ZERO; //本年其他部分划入个人账户本金,
                BigDecimal aae856 = BigDecimal.ZERO; //本年其他部分划入个人账户本金所产生的利息,
                BigDecimal aae857 = BigDecimal.ZERO; //截至本年末个人账户其他部分划转累计本息,
                BigDecimal aae873 = BigDecimal.ZERO; //本年本金总和,
                BigDecimal aae874 = BigDecimal.ZERO; //本年利息总和,
                BigDecimal aae875 = BigDecimal.ZERO; //本年补缴历年本金,
                BigDecimal aae876 = BigDecimal.ZERO; //本年补缴历年利息,
                //当年利率
                List<InterestRate> currentInterestRates = toYearsCurrentInterestRate.get(year);
                BigDecimal current_aaa031; // 当年利率
                BigDecimal overYears_aaa031; // 历年利率

                if (year.intValue() < endAae001 || year.intValue() > endAae001) {//如果不是计息截止日期，就取利率同年开始日期最大的那条
                    List<InterestRate> aaa031s = currentInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                    if (ValidateUtil.isNotEmpty(aaa031s)) {
                        current_aaa031 = currentInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList()).get(0).getAaa031();
                    } else {
                        current_aaa031 = BigDecimal.ZERO;
                        //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                    }
                } else {//计息截止日期
                    currentInterestRates = toYearsCurrentInterestRate.get(endAae001);
                    if (ValidateUtil.isNotEmpty(currentInterestRates)) {
                        List<InterestRate> aaa031s = currentInterestRates.stream().filter(interestRate -> interestRate.getAae041() <= this.aae042 && this.aae042 <= interestRate.getAae042()).collect(Collectors.toList());
                        if (ValidateUtil.isNotEmpty(aaa031s)) {
                            current_aaa031 = aaa031s.get(0).getAaa031();
                        } else {
                            current_aaa031 = BigDecimal.ZERO;
                            //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                        }
                    } else {
                        current_aaa031 = BigDecimal.ZERO;
                        //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                    }
                }
                //历年利率
                List<InterestRate> overInterestRates = toYearsOverInterestRate.get(year);
                if (year.intValue() < endAae001 || year.intValue() > endAae001) {
                    List<InterestRate> aaa031s = overInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                    if (ValidateUtil.isNotEmpty(aaa031s)) {
                        overYears_aaa031 = overInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList()).get(0).getAaa031();
                    } else {
                        overYears_aaa031 = BigDecimal.ZERO;
                        //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                    }
                } else {
                    overInterestRates = toYearsOverInterestRate.get(endAae001);
                    if (ValidateUtil.isNotEmpty(overInterestRates)) {
                        List<InterestRate> aaa031s = overInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                        if (ValidateUtil.isNotEmpty(aaa031s)) {
                            overYears_aaa031 = aaa031s.get(0).getAaa031();
                        } else {
                            overYears_aaa031 = BigDecimal.ZERO;
//                            throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                        }
                    } else {
                        overYears_aaa031 = BigDecimal.ZERO;
//                        throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                    }
                }
                if (jxAae001.intValue() == year.intValue()) {//转入当年计息
                    if (ValidateUtil.isNotEmpty(allAc08List)) {
                        //List<MyMap> allAc08MapList = ListUtil.mapList2MyMapList(allAc08List);
                        //List<Map> transferAc08s = allAc08MapList.stream().filter(myMap -> Constant.AAA115_10_ZCYJ.equals(myMap.getAsString("aaa115")) && Constant.AAE793_1061_ZR.equals(myMap.getAsString("aae793"))).collect(Collectors.toList());
                        if (ValidateUtil.isNotEmpty(transferAc08s)) {//没有收入明细
                            List<MyMap> transferAc08myMaps = ListUtil.mapList2MyMapList(transferAc08s);
                            AnnualConversionTransverse annuals = businessAae001Map.get(year).get(0);
                            if (null != annuals) {
                                //所有转入缴费类型
                                List<String> aae793_zralls = new ArrayList<>();
                                aae793_zralls.add(Constant.AAE793_1061_ZR);
                                aae793_zralls.add(Constant.AAE793_1062_JGZR);
                                aae793_zralls.add(Constant.AAE793_1063_CXZR);
                                aae793_zralls.add(Constant.AAE793_1064_JRZR);
                                List<MyMap> transferPaymentDetails = transferAc08myMaps.stream().filter(myMap -> !myMap.getAsString("aae793").equals(Constant.AAE793_9022_CJZHTSMX) &&
                                        aae793_zralls.contains(myMap.getAsString("aae793")) &&
                                        myMap.getAsInteger("aae003") >= annuals.getAae041() &&
                                        myMap.getAsInteger("aae003") <= annuals.getAae042()).collect(Collectors.toList());
                                if (ValidateUtil.isNotEmpty(transferPaymentDetails)) {
                                    BigDecimal aae789 = new BigDecimal(0);
                                    BigDecimal aae791 = new BigDecimal(0);
                                    for (MyMap myMap : transferPaymentDetails) {
                                        BigDecimal aae081 = myMap.getAsBigDecimalNullToZero("aae081"); //单位实缴划入个人账户金额
                                        BigDecimal aae083 = myMap.getAsBigDecimalNullToZero("aae083"); //个人实缴划入个人账户金额
                                        aae789 = aae789.add(myMap.getAsBigDecimalNullToZero("aae789")); //单位实缴划入个人账户金额利息
                                        aae791 = aae791.add(myMap.getAsBigDecimalNullToZero("aae791")); //个人实缴划入个人账户金额利息
                                        aae262 = aae262.add(aae081);//单位实缴划入个人账户金额+单位实缴划入个人账户金额利息
                                        aae264 = aae264.add(aae083);//个人实缴划入个人账户金额+个人实缴划入个人账户金额利息


                                    }

                                    //当年利息（2006前:本金*利率*实缴/12/2;2006后:本金*利率*1.083/2）
                                    aae263 = AccountCalculatInter.calculatThisYearInter(aae262, current_aaa031, 12, year, endAae001);
                                    if (aae789.compareTo(BigDecimal.ZERO) > 0) {
                                        aae263 = aae263.add(aae789);
                                    }
                                    aae265 = AccountCalculatInter.calculatThisYearInter(aae264, current_aaa031, 12, year, endAae001);
                                    if (aae791.compareTo(BigDecimal.ZERO) > 0) {
                                        aae265 = aae265.add(aae791);
                                    }
                                    /*if (year <= 2006) {
                                        //本年单位缴费部分划入个人账户本金所产生的利息
                                        aae263 = aae262.multiply(current_aaa031).multiply(BigDecimal.valueOf(12)).divide(BigDecimal.valueOf(12)).divide(BigDecimal.valueOf(2)).setScale(2, BigDecimal.ROUND_HALF_UP);
                                        //本年个人缴费部分划入个人账户本金所产生的利息
                                        aae265 = aae264.multiply(current_aaa031).multiply(BigDecimal.valueOf(12)).divide(BigDecimal.valueOf(12)).divide(BigDecimal.valueOf(2)).setScale(2, BigDecimal.ROUND_HALF_UP);
                                    } else {
                                        //本年单位缴费部分划入个人账户本金所产生的利息
                                        aae263 = aae262.multiply(current_aaa031).multiply(BigDecimal.valueOf(1.083)).divide(BigDecimal.valueOf(2)).setScale(2, BigDecimal.ROUND_HALF_UP);
                                        //本年个人缴费部分划入个人账户本金所产生的利息
                                        aae265 = aae264.multiply(current_aaa031).multiply(BigDecimal.valueOf(1.083)).divide(BigDecimal.valueOf(2)).setScale(2, BigDecimal.ROUND_HALF_UP);
                                    }*/
                                }
                            }
                        } else {// TODO: 2022/9/27 转入当年存不存在缴费明细
                            if (ValidateUtil.isNotEmpty(mapTransFers.get(year))) {
                                MyMap tranmyMap = mapTransFers.get(year).get(0);
                                aae262 = tranmyMap.getAsBigDecimalNullToZero("aae262");
                                aae264 = tranmyMap.getAsBigDecimalNullToZero("aae264");
                                aae263 = AccountCalculatInter.calculatThisYearInter(aae262, current_aaa031, 12, year, endAae001);
                                aae265 = AccountCalculatInter.calculatThisYearInter(aae264, current_aaa031, 12, year, endAae001);
                            }
                        }
                    } else {// TODO: 2022/9/27 转入当年存不存在缴费明细
                        if (ValidateUtil.isNotEmpty(mapTransFers.get(year))) {
                            MyMap tranmyMap = mapTransFers.get(year).get(0);
                            aae262 = tranmyMap.getAsBigDecimalNullToZero("aae262");
                            aae264 = tranmyMap.getAsBigDecimalNullToZero("aae264");
                            aae263 = AccountCalculatInter.calculatThisYearInter(aae262, current_aaa031, 12, year, endAae001);
                            aae265 = AccountCalculatInter.calculatThisYearInter(aae264, current_aaa031, 12, year, endAae001);
                        }
                    }
                }
                Integer overYear = year - 1;
                if (first_falg == 0) {
                    List<MyMap> overYearList_first = transferMyMapAccountAc51s.stream().filter(myMap -> myMap.getAsInteger("aae001").intValue() == overYear.intValue()).collect(Collectors.toList());
                    overAllYearList.addAll(overYearList_first);
                    first_falg = first_falg + 1;
                }
                Optional<MyMap> ac51Opt = overAllYearList.stream().filter(myMap -> myMap.getAsInteger("aae001").intValue() == overYear.intValue()).findAny();
                MyMap ac51Mymap = null;
                BigDecimal oldaae849 = BigDecimal.ZERO;
                BigDecimal oldaae259 = BigDecimal.ZERO;
                BigDecimal oldaae262 = BigDecimal.ZERO;
                BigDecimal oldaae263 = BigDecimal.ZERO;
                BigDecimal oldaae851 = BigDecimal.ZERO;
                BigDecimal oldaae260 = BigDecimal.ZERO;
                BigDecimal oldaae264 = BigDecimal.ZERO;
                BigDecimal oldaae265 = BigDecimal.ZERO;
                BigDecimal oldaae853 = BigDecimal.ZERO;
                BigDecimal oldaae854 = BigDecimal.ZERO;
                BigDecimal oldaae855 = BigDecimal.ZERO;
                BigDecimal oldaae856 = BigDecimal.ZERO;
                if (ac51Opt.isPresent()) {
                    ac51Mymap = ac51Opt.get();
                    oldaae849 = ac51Mymap.getAsBigDecimalNullToZero("aae849");//截至上年末个人账户单位缴费部分划转累计本息,
                    oldaae259 = ac51Mymap.getAsBigDecimalNullToZero("aae259");//截至上年末个人账户单位缴费部分划转本息在本年产生的利息,
                    oldaae262 = ac51Mymap.getAsBigDecimalNullToZero("aae262");//本年单位缴费部分划入个人账户本金,
                    oldaae263 = ac51Mymap.getAsBigDecimalNullToZero("aae263");//本年单位缴费部分划入个人账户本金所产生的利息,
                    oldaae851 = ac51Mymap.getAsBigDecimalNullToZero("aae851");//截至上年末个人账户个人缴费部分划转累计本息,
                    oldaae260 = ac51Mymap.getAsBigDecimalNullToZero("aae260");//截至上年末个人账户个人缴费部分划转本息在本年产生的利息,
                    oldaae264 = ac51Mymap.getAsBigDecimalNullToZero("aae264");//本年个人缴费部分划入个人账户本金,
                    oldaae265 = ac51Mymap.getAsBigDecimalNullToZero("aae265");//本年个人缴费部分划入个人账户本金所产生的利息,
                    oldaae853 = ac51Mymap.getAsBigDecimalNullToZero("aae853");//截至上年末个人账户其他部分划转累计本息,
                    oldaae854 = ac51Mymap.getAsBigDecimalNullToZero("aae854");//截至上年末个人账户其他部分划转本息在本年产生的利息,
                    oldaae855 = ac51Mymap.getAsBigDecimalNullToZero("aae855");//本年其他部分划入个人账户本金,
                    oldaae856 = ac51Mymap.getAsBigDecimalNullToZero("aae856");//本年其他部分划入个人账户本金所产生的利息,
                }
                //截至上年末个人账户单位缴费部分划转累计本息=上一年（截至上年末个人账户单位缴费部分划转累计本息+截至上年末个人账户单位缴费部分划转本息在本年产生的利息+本年单位缴费部分划入个人账户本金+本年单位缴费部分划入个人账户本金所产生的利息）
                //其实截至上年末个人账户单位缴费部分划转累计本息=上一年的截至本年末个人账户单位缴费部分划转累计本息
                aae849 = oldaae849.add(oldaae259).add(oldaae262).add(oldaae263);
                //截至上年末个人账户个人缴费部分划转累计本息=上一年（截至上年末个人账户个人缴费部分划转累计本息+截至上年末个人账户个人缴费部分划转本息在本年产生的利息+本年个人缴费部分划入个人账户本金+本年个人缴费部分划入个人账户本金所产生的利息）
                aae851 = oldaae851.add(oldaae260).add(oldaae264).add(oldaae265);
                //截至上年末个人账户其他部分划转累计本息,
                aae853 = oldaae853.add(oldaae854).add(oldaae855).add(oldaae856);

                List<AnnualConversionTransverse> annualConversions = businessAae001Map.get(year);
                AnnualConversionTransverse annual = annualConversions.get(0);

                aae259 = AccountCalculatInter.calculatPastYearInter(aae849, overYears_aaa031, annual.getBae084(), year, this.aae042, endAae001);
                aae260 = AccountCalculatInter.calculatPastYearInter(aae851, overYears_aaa031, annual.getBae084(), year, this.aae042, endAae001);
                aae854 = AccountCalculatInter.calculatPastYearInter(aae853, overYears_aaa031, annual.getBae084(), year, this.aae042, endAae001);
                /*if (year <= 2006) {
                    //2006前本金*利率/12*应缴月数
                    aae259 = ((aae849.multiply(overYears_aaa031)).divide(new BigDecimal(12))).multiply(new BigDecimal(12));
                    aae260 = ((aae851.multiply(overYears_aaa031)).divide(new BigDecimal(12))).multiply(new BigDecimal(12));
                    aae854 = ((aae853.multiply(overYears_aaa031)).divide(new BigDecimal(12))).multiply(new BigDecimal(12));
                    if (year.intValue() == endAae001.intValue()) {
                        Integer ys = this.aae042 % 100;
                        aae259 = aae259.multiply(BigDecimal.valueOf(ys)).divide(BigDecimal.valueOf(12), 4, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
                        aae260 = aae260.multiply(BigDecimal.valueOf(ys)).divide(BigDecimal.valueOf(12), 4, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
                        aae854 = aae854.multiply(BigDecimal.valueOf(ys)).divide(BigDecimal.valueOf(12), 4, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
                    }
                } else {
                    //本金*利率
                    aae259 = aae849.multiply(overYears_aaa031).setScale(2, BigDecimal.ROUND_HALF_UP);
                    aae260 = aae851.multiply(overYears_aaa031).setScale(2, BigDecimal.ROUND_HALF_UP);
                    aae854 = aae853.multiply(overYears_aaa031).setScale(2, BigDecimal.ROUND_HALF_UP);
                    if (year.intValue() == endAae001.intValue()) {
                        Integer ys = this.aae042 % 100;
                        aae259 = aae259.multiply(BigDecimal.valueOf(ys)).divide(BigDecimal.valueOf(12), 4, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
                        aae260 = aae260.multiply(BigDecimal.valueOf(ys)).divide(BigDecimal.valueOf(12), 4, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
                        aae854 = aae854.multiply(BigDecimal.valueOf(ys)).divide(BigDecimal.valueOf(12), 4, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
                    }
                }*/
                IndividualAccountParameter individualAccountParameter = new IndividualAccountParameter();
                individualAccountParameter.setAaz117("");
                individualAccountParameter.setAaz116(aaz116);
                individualAccountParameter.setAaa119(aaa119);
                individualAccountParameter.setAaa513(aaa513);
                individualAccountParameter.setAac001(this.aac001);
                individualAccountParameter.setAae001(year);
                individualAccountParameter.setAae849(aae849);
                individualAccountParameter.setAae259(aae259);
                individualAccountParameter.setAae262(aae262);
                individualAccountParameter.setAae263(aae263);
                aae850 = aae849.add(aae259).add(aae262).add(aae263);
                individualAccountParameter.setAae850(aae850);
                individualAccountParameter.setAae851(aae851);
                individualAccountParameter.setAae260(aae260);
                individualAccountParameter.setAae264(aae264);
                individualAccountParameter.setAae265(aae265);
                aae852 = aae851.add(aae260).add(aae264).add(aae265);
                individualAccountParameter.setAae852(aae852);
                individualAccountParameter.setAae853(aae853);
                individualAccountParameter.setAae854(aae854);
                individualAccountParameter.setAae855(aae855);
                individualAccountParameter.setAae856(aae856);
                aae857 = aae853.add(aae854).add(aae855).add(aae856);
                individualAccountParameter.setAae857(aae857);
                individualAccountParameter.setAae873(aae873);
                individualAccountParameter.setAae874(aae874);
                individualAccountParameter.setAae875(aae875);
                individualAccountParameter.setAae876(aae876);
                individualAccountParameter.setAaa031(current_aaa031);
                individualAccountParameter.setAae825(Constant.AAE825_0_F);
                individualAccountParameter.setAae100(Constant.AAE100_1_YX);
                individualAccountParameter.setAaz159(this.aaz159);
                individualAccountParameter.setAae013("转移账户计息");
                individualAccountParameter.setAaz673(aaz116AndAaz673Map.get(aaz116));
                individualAccountParameter.setAic376(this.aic376);
                individualAccountParameter.setActualPaymentMonths(12);
                zyhzList.add(individualAccountParameter);
                IndividualAccountParameters.add(individualAccountParameter);

                MyMap ocerMap = new MyMap();
                ocerMap.put("aae849", aae849);//截至上年末个人账户单位缴费部分划转累计本息,
                ocerMap.put("aae259", aae259);//截至上年末个人账户单位缴费部分划转本息在本年产生的利息,
                ocerMap.put("aae262", aae262);//本年单位缴费部分划入个人账户本金,
                ocerMap.put("aae263", aae263);//本年单位缴费部分划入个人账户本金所产生的利息,
                ocerMap.put("aae851", aae851);//截至上年末个人账户个人缴费部分划转累计本息,
                ocerMap.put("aae260", aae260);//截至上年末个人账户个人缴费部分划转本息在本年产生的利息,
                ocerMap.put("aae264", aae264);//本年个人缴费部分划入个人账户本金,
                ocerMap.put("aae265", aae265);//本年个人缴费部分划入个人账户本金所产生的利息,
                ocerMap.put("aae853", aae853);//截至上年末个人账户其他部分划转累计本息,
                ocerMap.put("aae854", aae854);//截至上年末个人账户其他部分划转本息在本年产生的利息,
                ocerMap.put("aae855", aae855);//本年其他部分划入个人账户本金,
                ocerMap.put("aae856", aae856);//本年其他部分划入个人账户本金所产生的利息,
                ocerMap.put("aae001", year);//本年其他部分划入个人账户本金所产生的利息,
                overAllYearList.add(ocerMap);

                year = year + 1;

            }
        }
        for (IndividualAccountParameter individualAccountParameter : zyhzList) {
            aae238 = aae238.add(individualAccountParameter.getAae262()).add(individualAccountParameter.getAae264()).add(individualAccountParameter.getAae855());
            aae239 = aae239.add(individualAccountParameter.getAae259()).add(individualAccountParameter.getAae263()).add(individualAccountParameter.getAae260()).add(individualAccountParameter.getAae265()).add(individualAccountParameter.getAae854()).add(individualAccountParameter.getAae856());

        }
        IndividualAccountParameter trAae240 = zyhzList.stream().max(Comparator.comparing(in -> in.getAae001())).get();
        BigDecimal trae240Tz = trAae240.getAae849().add(trAae240.getAae259()).add(trAae240.getAae262())
                .add(trAae240.getAae263()).add(trAae240.getAae851()).add(trAae240.getAae260()).add(trAae240.getAae264())
                .add(trAae240.getAae265()).add(trAae240.getAae853()).add(trAae240.getAae854()).add(trAae240.getAae855()).add(trAae240.getAae856());
        trae240Tz = trae240Tz.subtract(aae238_kj[0]).subtract(aae239_kj[0]);
//        aae240 = aae238.add(aae239);
        aae238 = aae238.subtract(aae238_kj[0]);
        aae239 = aae239.subtract(aae239_kj[0]);
        aae240 = aae238.add(aae239);
        if (trae240Tz.compareTo(aae240) != 0) {
            BigDecimal ce = trae240Tz.subtract(aae240);
            aae240 = trae240Tz;
            aae239 = aae239.add(ce);
        }
        IndividualAccount individualAccount = new IndividualAccount();
        individualAccount.setAaz116(aaz116);
        individualAccount.setAac001(aac001);
        individualAccount.setAaa119(aaa119);
        individualAccount.setAac062(aac062);
        individualAccount.setAaa513(aaa513);
        individualAccount.setAae206(aae206);
        individualAccount.setAic376(this.aic376);
        individualAccount.setAae238(aae238);
        individualAccount.setAae239(aae239);
        individualAccount.setAae240(aae240);
        individualAccount.setAae100(Constant.AAE100_1_YX);
        individualAccount.setAaz159(aaz159);
        individualAccount.setAae013("转移账户计息");

        individualAccount.setAaz673(aaz116AndAaz673Map.get(aaz116));
        individualAccount.setAae368(Constant.AAE368_0_F);
        IndividualAccounts.add(individualAccount);
    }

    /**
     * @param aaz116 aaz116
     * @Description 计算采集账户
     * @Author jzy
     * @Date 2022/01/03
     */
    protected void calculateEntryAccount(String aaz116, String aaa119, String aac062, String aaa513, Integer aae206) {
        BigDecimal aae238 = BigDecimal.ZERO;
        BigDecimal aae239 = BigDecimal.ZERO;
        BigDecimal aae240 = BigDecimal.ZERO;
        Map queryMap = new HashMap();
        queryMap.put("aaz116", aaz116);
//        List<Map> entryAccountAc51s = NationalQueryRegister.einpCollectionQueryService().getAC51(queryMap);
        List<Map> entryAccountAc51s = new ArrayList<>();
//        List<Map> ac50a4s = RepositoryRegister.accountInfoHandleMapper().getAC50A4(queryMap);
        List<Map> ac50a4s = new ArrayList<>();
        List<MyMap> ac50a4MyMaps = ListUtil.list2MyMapList(ac50a4s);
        Map<String, List<MyMap>> mapAc50a4Map = null;
        if (ValidateUtil.isNotEmpty(ac50a4MyMaps)) {
            mapAc50a4Map = ac50a4MyMaps.stream().collect(Collectors.groupingBy(mm -> mm.getAsString("aae001")));
        }

        if (ValidateUtil.isNotEmpty(entryAccountAc51s)) {
            //空账户不进行计息
            List<MyMap> checkEntryAccountAc51s = ListUtil.mapList2MyMapList(entryAccountAc51s);
            List<MyMap> cck = checkEntryAccountAc51s.stream().filter(mm ->
                    mm.getAsBigDecimalNullToZero("aae262").compareTo(BigDecimal.ZERO) > 0 ||
                            mm.getAsBigDecimalNullToZero("aae264").compareTo(BigDecimal.ZERO) > 0 ||
                            mm.getAsBigDecimalNullToZero("aae855").compareTo(BigDecimal.ZERO) > 0 ||
                            mm.getAsBigDecimalNullToZero("aae850").compareTo(BigDecimal.ZERO) > 0 ||
                            mm.getAsBigDecimalNullToZero("aae852").compareTo(BigDecimal.ZERO) > 0 ||
                            mm.getAsBigDecimalNullToZero("aae857").compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
            if (ValidateUtil.isEmpty(cck)) {//空台账返回
                return;
            }
            List<MyMap> entryMyMapAccountAc51s = ListUtil.mapList2MyMapList(entryAccountAc51s);
            List<MyMap> entryPay = entryMyMapAccountAc51s.stream().filter(myMap -> (myMap.getAsBigDecimalNullToZero("aae262").add(myMap.getAsBigDecimalNullToZero("aae264")).add(myMap.getAsBigDecimalNullToZero("aae855"))).compareTo(BigDecimal.ZERO) > 0).collect(Collectors.toList());
            if (ValidateUtil.isEmpty(entryPay)) {//空台账返回
                Integer minaae001 = entryMyMapAccountAc51s.stream().min(Comparator.comparing(myMap -> myMap.getAsInteger("aae001"))).orElseGet(MyMap::new).getAsInteger("aae001");
                List<MyMap> ckJzqList = entryMyMapAccountAc51s.stream().filter(myMap -> (myMap.getAsBigDecimalNullToZero("aae849").add(myMap.getAsBigDecimalNullToZero("aae851")).add(myMap.getAsBigDecimalNullToZero("aae853"))).compareTo(BigDecimal.ZERO) > 0
                        && myMap.getAsInteger("aae001").intValue() == minaae001.intValue()).collect(Collectors.toList());
                if (ValidateUtil.isNotEmpty(ckJzqList)) {//存在建账前的，需要累加更新ac50
                    BigDecimal jzqAae849 = entryMyMapAccountAc51s.stream().min(Comparator.comparing(myMap -> myMap.getAsInteger("aae001"))).orElseGet(MyMap::new).getAsBigDecimalNullToZero("aae849");
                    BigDecimal jzqAae851 = entryMyMapAccountAc51s.stream().min(Comparator.comparing(myMap -> myMap.getAsInteger("aae001"))).orElseGet(MyMap::new).getAsBigDecimalNullToZero("aae851");
                    BigDecimal aae262_jxq = BigDecimal.ZERO;
                    BigDecimal aae264_jxq = BigDecimal.ZERO;
                    BigDecimal aae855_jxq = BigDecimal.ZERO;
                    BigDecimal aae259_jxq = BigDecimal.ZERO;
                    BigDecimal aae263_jxq = BigDecimal.ZERO;
                    BigDecimal aae260_jxq = BigDecimal.ZERO;
                    BigDecimal aae265_jxq = BigDecimal.ZERO;
                    BigDecimal aae854_jxq = BigDecimal.ZERO;
                    BigDecimal aae856_jxq = BigDecimal.ZERO;
                    for (MyMap myMap : entryMyMapAccountAc51s) {
                        aae262_jxq = aae262_jxq.add(myMap.getAsBigDecimalNullToZero("aae262"));
                        aae264_jxq = aae264_jxq.add(myMap.getAsBigDecimalNullToZero("aae264"));
                        aae855_jxq = aae855_jxq.add(myMap.getAsBigDecimalNullToZero("aae855"));
                        aae259_jxq = aae259_jxq.add(myMap.getAsBigDecimalNullToZero("aae259"));
                        aae263_jxq = aae263_jxq.add(myMap.getAsBigDecimalNullToZero("aae263"));
                        aae260_jxq = aae260_jxq.add(myMap.getAsBigDecimalNullToZero("aae260"));
                        aae265_jxq = aae265_jxq.add(myMap.getAsBigDecimalNullToZero("aae265"));
                        aae854_jxq = aae854_jxq.add(myMap.getAsBigDecimalNullToZero("aae854"));
                        aae856_jxq = aae856_jxq.add(myMap.getAsBigDecimalNullToZero("aae856"));
                    }
                    aae238 = aae238.add(aae262_jxq).add(aae264_jxq).add(aae855_jxq).add(jzqAae849).add(jzqAae851);
                    aae239 = aae239.add(aae259_jxq).add(aae263_jxq).add(aae260_jxq).add(aae265_jxq).add(aae854_jxq).add(aae856_jxq);
                    IndividualAccount individualAccount = new IndividualAccount();
                    individualAccount.setAaz116(aaz116);
                    individualAccount.setAac001(aac001);
                    individualAccount.setAaa119(aaa119);
                    individualAccount.setAac062(aac062);
                    individualAccount.setAaa513(Constant.AAA513_2_LZH);
                    individualAccount.setAae206(aae206);
                    individualAccount.setAic376(this.aic376);
                    individualAccount.setAae238(aae238);
                    individualAccount.setAae239(aae239);
                    individualAccount.setAae240(aae238.add(aae239));
                    individualAccount.setAae100(Constant.AAE100_1_YX);
                    individualAccount.setAaz159(aaz159);
                    individualAccount.setAae013("采集账户计息");

                    individualAccount.setAae368(Constant.AAE368_0_F);
                    IndividualAccounts.add(individualAccount);
                    return;
                } else {
                    return;
                }

            }
            List<MyMap> aae825MyMap = entryMyMapAccountAc51s.stream().filter(myMap -> Constant.AAE825_1_S.equals(myMap.getAsString("aae825"))).collect(Collectors.toList());

            Integer beginAae001 = entryPay.stream().max(Comparator.comparing(myMap -> myMap.getAsInteger("aae001"))).orElseGet(MyMap::new).getAsInteger("aae001");

            List<MyMap> entryPayJzq = entryMyMapAccountAc51s.stream().filter(myMap -> myMap.getAsInteger("aae001").intValue() <= beginAae001).collect(Collectors.toList());

            BigDecimal jzqAae849 = entryPayJzq.stream().min(Comparator.comparing(myMap -> myMap.getAsInteger("aae001"))).orElseGet(MyMap::new).getAsBigDecimalNullToZero("aae849");
            BigDecimal jzqAae851 = entryPayJzq.stream().min(Comparator.comparing(myMap -> myMap.getAsInteger("aae001"))).orElseGet(MyMap::new).getAsBigDecimalNullToZero("aae851");

            BigDecimal aae262_jxq = BigDecimal.ZERO;
            BigDecimal aae264_jxq = BigDecimal.ZERO;
            BigDecimal aae855_jxq = BigDecimal.ZERO;
            BigDecimal aae259_jxq = BigDecimal.ZERO;
            BigDecimal aae263_jxq = BigDecimal.ZERO;
            BigDecimal aae260_jxq = BigDecimal.ZERO;
            BigDecimal aae265_jxq = BigDecimal.ZERO;
            BigDecimal aae854_jxq = BigDecimal.ZERO;
            BigDecimal aae856_jxq = BigDecimal.ZERO;
            for (MyMap myMap : entryPayJzq) {
                aae262_jxq = aae262_jxq.add(myMap.getAsBigDecimalNullToZero("aae262"));
                aae264_jxq = aae264_jxq.add(myMap.getAsBigDecimalNullToZero("aae264"));
                aae855_jxq = aae855_jxq.add(myMap.getAsBigDecimalNullToZero("aae855"));
                aae259_jxq = aae259_jxq.add(myMap.getAsBigDecimalNullToZero("aae259"));
                aae263_jxq = aae263_jxq.add(myMap.getAsBigDecimalNullToZero("aae263"));
                aae260_jxq = aae260_jxq.add(myMap.getAsBigDecimalNullToZero("aae260"));
                aae265_jxq = aae265_jxq.add(myMap.getAsBigDecimalNullToZero("aae265"));
                aae854_jxq = aae854_jxq.add(myMap.getAsBigDecimalNullToZero("aae854"));
                aae856_jxq = aae856_jxq.add(myMap.getAsBigDecimalNullToZero("aae856"));
            }
            aae238 = aae238.add(aae262_jxq).add(aae264_jxq).add(aae855_jxq).add(jzqAae849).add(jzqAae851);
            aae239 = aae239.add(aae259_jxq).add(aae263_jxq).add(aae260_jxq).add(aae265_jxq).add(aae854_jxq).add(aae856_jxq);

            Integer year = beginAae001 + 1;
            Integer endAae001;
            if (null != this.aae042) {
                endAae001 = getBusinessYear(this.aae042);
            } else {
                endAae001 = nowaae001;
            }
            Integer incomeDeadlineYear = endAae001;
            if (incomeDeadlineYear.intValue() < nowaae001.intValue()) {
                incomeDeadlineYear = nowaae001;
            }

            Map deleteMap = new HashMap();
            deleteMap.put(aaz116, beginAae001 + 1);
            deleteAaz116s.add(deleteMap);
            List<IndividualAccountParameter> cjhzList = new ArrayList<>();
            List<MyMap> overAllLists = new ArrayList<>();
            int firstFalg = 0;
            Map<String, List<MyMap>> aae82M = null;
            if (ValidateUtil.isNotEmpty(aae825MyMap)) {
                aae82M = aae825MyMap.stream().collect(Collectors.groupingBy(ml -> ml.getAsString("aae001")));
            }
            while (year <= incomeDeadlineYear) {
                BigDecimal aae849; //截至上年末个人账户单位缴费部分划转累计本息,
                BigDecimal aae259; //截至上年末个人账户单位缴费部分划转本息在本年产生的利息,
                BigDecimal aae262 = BigDecimal.ZERO; //本年单位缴费部分划入个人账户本金,
                BigDecimal aae263 = BigDecimal.ZERO; //本年单位缴费部分划入个人账户本金所产生的利息,
                BigDecimal aae850 = BigDecimal.ZERO; //截至本年末个人账户单位缴费部分划转累计本息,
                BigDecimal aae851; //截至上年末个人账户个人缴费部分划转累计本息,
                BigDecimal aae260; //截至上年末个人账户个人缴费部分划转本息在本年产生的利息,
                BigDecimal aae264 = BigDecimal.ZERO; //本年个人缴费部分划入个人账户本金,
                BigDecimal aae265 = BigDecimal.ZERO; //本年个人缴费部分划入个人账户本金所产生的利息,
                BigDecimal aae852 = BigDecimal.ZERO; //截至本年末个人账户个人缴费部分划转累计本息,
                BigDecimal aae853; //截至上年末个人账户其他部分划转累计本息,
                BigDecimal aae854; //截至上年末个人账户其他部分划转本息在本年产生的利息,
                BigDecimal aae855 = BigDecimal.ZERO; //本年其他部分划入个人账户本金,
                BigDecimal aae856 = BigDecimal.ZERO; //本年其他部分划入个人账户本金所产生的利息,
                BigDecimal aae857 = BigDecimal.ZERO; //截至本年末个人账户其他部分划转累计本息,
                BigDecimal aae873 = BigDecimal.ZERO; //本年本金总和,
                BigDecimal aae874 = BigDecimal.ZERO; //本年利息总和,
                BigDecimal aae875 = BigDecimal.ZERO; //本年补缴历年本金,
                BigDecimal aae876 = BigDecimal.ZERO; //本年补缴历年利息,

                //当年利率
                List<InterestRate> currentInterestRates = toYearsCurrentInterestRate.get(year);
                BigDecimal current_aaa031; // 当年利率
                BigDecimal overYears_aaa031; // 历年利率
                List<MyMap> aae825MyMapll = null;
                if (!ValidateUtil.isEmpty(mapAc50a4Map) && !ValidateUtil.isEmpty(aae82M)) {//手工录入标志为1并且查询的录入的利率，按照手工录入利率进行计息
                    List<MyMap> ac50a4MyMapll = mapAc50a4Map.get(year.toString());
                    aae825MyMapll = aae82M.get(year.toString());
                    if (ValidateUtil.isNotEmpty(ac50a4MyMapll) && ValidateUtil.isNotEmpty(aae825MyMapll)) {
                        current_aaa031 = ac50a4MyMapll.get(0).getAsBigDecimalNullToZero("baa054");//当年利率
                        overYears_aaa031 = ac50a4MyMapll.get(0).getAsBigDecimalNullToZero("baa055");//当年利率
                    } else {
                        if (year.intValue() < endAae001 || year.intValue() > endAae001) {//如果不是计息截止日期，就取利率同年开始日期最大的那条
                            List<InterestRate> aaa031s = currentInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                            if (ValidateUtil.isNotEmpty(aaa031s)) {
                                current_aaa031 = aaa031s.get(0).getAaa031();
                            } else {
                                current_aaa031 = BigDecimal.ZERO;
//                        throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                            }
                        } else {//计息截止日期
                            currentInterestRates = toYearsCurrentInterestRate.get(endAae001);
                            if (ValidateUtil.isNotEmpty(currentInterestRates)) {
                                List<InterestRate> aaa031s = currentInterestRates.stream().filter(interestRate -> interestRate.getAae041() <= this.aae042 && this.aae042 <= interestRate.getAae042()).collect(Collectors.toList());
                                if (ValidateUtil.isNotEmpty(aaa031s)) {
                                    current_aaa031 = aaa031s.get(0).getAaa031();
                                } else {
                                    current_aaa031 = BigDecimal.ZERO;
//                            throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                                }
                            } else {
                                current_aaa031 = BigDecimal.ZERO;
                                //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                            }
                        }
                        //历年利率
                        List<InterestRate> overInterestRates = toYearsOverInterestRate.get(year);
                        if (year.intValue() < endAae001 || year.intValue() > endAae001) {
                            List<InterestRate> aaa031s = overInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                            if (ValidateUtil.isNotEmpty(aaa031s)) {
                                overYears_aaa031 = aaa031s.get(0).getAaa031();
                            } else {
                                overYears_aaa031 = BigDecimal.ZERO;
                                //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                            }
                        } else {
                            overInterestRates = toYearsOverInterestRate.get(endAae001);
                            if (ValidateUtil.isNotEmpty(overInterestRates)) {
                                List<InterestRate> aaa031s = overInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                                if (ValidateUtil.isNotEmpty(aaa031s)) {
                                    overYears_aaa031 = aaa031s.get(0).getAaa031();
                                } else {
                                    overYears_aaa031 = BigDecimal.ZERO;
                                    //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                                }
                            } else {
                                overYears_aaa031 = BigDecimal.ZERO;
                                // throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                            }
                        }
                    }

                } else {
                    if (year.intValue() < endAae001 || year.intValue() > endAae001) {//如果不是计息截止日期，就取利率同年开始日期最大的那条
                        List<InterestRate> aaa031s = currentInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                        if (ValidateUtil.isNotEmpty(aaa031s)) {
                            current_aaa031 = aaa031s.get(0).getAaa031();
                        } else {
                            current_aaa031 = BigDecimal.ZERO;
//                        throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                        }
                    } else {//计息截止日期
                        currentInterestRates = toYearsCurrentInterestRate.get(endAae001);
                        if (ValidateUtil.isNotEmpty(currentInterestRates)) {
                            List<InterestRate> aaa031s = currentInterestRates.stream().filter(interestRate -> interestRate.getAae041() <= this.aae042 && this.aae042 <= interestRate.getAae042()).collect(Collectors.toList());
                            if (ValidateUtil.isNotEmpty(aaa031s)) {
                                current_aaa031 = aaa031s.get(0).getAaa031();
                            } else {
                                current_aaa031 = BigDecimal.ZERO;
//                            throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                            }
                        } else {
                            current_aaa031 = BigDecimal.ZERO;
                            //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                        }
                    }
                    //历年利率
                    List<InterestRate> overInterestRates = toYearsOverInterestRate.get(year);
                    if (year.intValue() < endAae001 || year.intValue() > endAae001) {
                        List<InterestRate> aaa031s = overInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                        if (ValidateUtil.isNotEmpty(aaa031s)) {
                            overYears_aaa031 = aaa031s.get(0).getAaa031();
                        } else {
                            overYears_aaa031 = BigDecimal.ZERO;
                            //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                        }
                    } else {
                        overInterestRates = toYearsOverInterestRate.get(endAae001);
                        if (ValidateUtil.isNotEmpty(overInterestRates)) {
                            List<InterestRate> aaa031s = overInterestRates.stream().sorted(Comparator.comparing(InterestRate::getAae041).reversed()).collect(Collectors.toList());
                            if (ValidateUtil.isNotEmpty(aaa031s)) {
                                overYears_aaa031 = aaa031s.get(0).getAaa031();
                            } else {
                                overYears_aaa031 = BigDecimal.ZERO;
                                //throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                            }
                        } else {
                            overYears_aaa031 = BigDecimal.ZERO;

                            // throw new IllegalArgumentException("没有获取到" + year + "年" + "利率!");
                        }
                    }
                }
                Integer overYear = year - 1;
                List<MyMap> overLists = new ArrayList();
                if (firstFalg == 0) {
                    List<MyMap> overLists_first = entryMyMapAccountAc51s.stream().filter(myMap -> myMap.getAsInteger("aae001").intValue() == overYear.intValue()).collect(Collectors.toList());
                    overAllLists.addAll(overLists_first);
                    overLists.addAll(overLists_first);
                    firstFalg = firstFalg + 1;
                } else {
                    List<MyMap> overListss = overAllLists.stream().filter(myMap -> myMap.getAsInteger("aae001").intValue() == overYear.intValue()).collect(Collectors.toList());
                    overLists = overListss;
                }
                MyMap ac51Mymap;
                BigDecimal oldaae849 = BigDecimal.ZERO;
                BigDecimal oldaae259 = BigDecimal.ZERO;
                BigDecimal oldaae262 = BigDecimal.ZERO;
                BigDecimal oldaae263 = BigDecimal.ZERO;
                BigDecimal oldaae851 = BigDecimal.ZERO;
                BigDecimal oldaae260 = BigDecimal.ZERO;
                BigDecimal oldaae264 = BigDecimal.ZERO;
                BigDecimal oldaae265 = BigDecimal.ZERO;
                BigDecimal oldaae853 = BigDecimal.ZERO;
                BigDecimal oldaae854 = BigDecimal.ZERO;
                BigDecimal oldaae855 = BigDecimal.ZERO;
                BigDecimal oldaae856 = BigDecimal.ZERO;
                if (ValidateUtil.isNotEmpty(overLists)) {
                    ac51Mymap = overLists.get(0);
                    oldaae849 = ac51Mymap.getAsBigDecimalNullToZero("aae849");//截至上年末个人账户单位缴费部分划转累计本息,
                    oldaae259 = ac51Mymap.getAsBigDecimalNullToZero("aae259");//截至上年末个人账户单位缴费部分划转本息在本年产生的利息,
                    oldaae262 = ac51Mymap.getAsBigDecimalNullToZero("aae262");//本年单位缴费部分划入个人账户本金,
                    oldaae263 = ac51Mymap.getAsBigDecimalNullToZero("aae263");//本年单位缴费部分划入个人账户本金所产生的利息,
                    oldaae851 = ac51Mymap.getAsBigDecimalNullToZero("aae851");//截至上年末个人账户个人缴费部分划转累计本息,
                    oldaae260 = ac51Mymap.getAsBigDecimalNullToZero("aae260");//截至上年末个人账户个人缴费部分划转本息在本年产生的利息,
                    oldaae264 = ac51Mymap.getAsBigDecimalNullToZero("aae264");//本年个人缴费部分划入个人账户本金,
                    oldaae265 = ac51Mymap.getAsBigDecimalNullToZero("aae265");//本年个人缴费部分划入个人账户本金所产生的利息,
                    oldaae853 = ac51Mymap.getAsBigDecimalNullToZero("aae853");//截至上年末个人账户其他部分划转累计本息,
                    oldaae854 = ac51Mymap.getAsBigDecimalNullToZero("aae854");//截至上年末个人账户其他部分划转本息在本年产生的利息,
                    oldaae855 = ac51Mymap.getAsBigDecimalNullToZero("aae855");//本年其他部分划入个人账户本金,
                    oldaae856 = ac51Mymap.getAsBigDecimalNullToZero("aae856");//本年其他部分划入个人账户本金所产生的利息,

                }
                //截至上年末个人账户单位缴费部分划转累计本息=上一年（截至上年末个人账户单位缴费部分划转累计本息+截至上年末个人账户单位缴费部分划转本息在本年产生的利息+本年单位缴费部分划入个人账户本金+本年单位缴费部分划入个人账户本金所产生的利息）
                //其实截至上年末个人账户单位缴费部分划转累计本息=上一年的截至本年末个人账户单位缴费部分划转累计本息
                aae849 = oldaae849.add(oldaae259).add(oldaae262).add(oldaae263);
                //截至上年末个人账户个人缴费部分划转累计本息=上一年（截至上年末个人账户个人缴费部分划转累计本息+截至上年末个人账户个人缴费部分划转本息在本年产生的利息+本年个人缴费部分划入个人账户本金+本年个人缴费部分划入个人账户本金所产生的利息）
                aae851 = oldaae851.add(oldaae260).add(oldaae264).add(oldaae265);
                //截至上年末个人账户其他部分划转累计本息,
                aae853 = oldaae853.add(oldaae854).add(oldaae855).add(oldaae856);

                List<AnnualConversionTransverse> annualConversions = businessAae001Map.get(year);
                AnnualConversionTransverse annual = annualConversions.get(0);

                aae259 = AccountCalculatInter.calculatPastYearInter(aae849, overYears_aaa031, annual.getBae084(), year, this.aae042, endAae001);
                aae260 = AccountCalculatInter.calculatPastYearInter(aae851, overYears_aaa031, annual.getBae084(), year, this.aae042, endAae001);
                aae854 = AccountCalculatInter.calculatPastYearInter(aae853, overYears_aaa031, annual.getBae084(), year, this.aae042, endAae001);
                /*if (year <= 2006) {
                    //2006前本金*实缴月数*利率/12/2
                    aae259 = ((aae849.multiply(overYears_aaa031)).divide(new BigDecimal(12))).multiply(new BigDecimal(12)).setScale(2, BigDecimal.ROUND_HALF_UP);
                    aae260 = ((aae851.multiply(overYears_aaa031)).divide(new BigDecimal(12))).multiply(new BigDecimal(12)).setScale(2, BigDecimal.ROUND_HALF_UP);
                    aae854 = ((aae853.multiply(overYears_aaa031)).divide(new BigDecimal(12))).multiply(new BigDecimal(12)).setScale(2, BigDecimal.ROUND_HALF_UP);
                    if (year.intValue() == endAae001.intValue()) {
                        Integer ys = this.aae042 % 100;
                        aae259 = aae849.multiply(overYears_aaa031).multiply(BigDecimal.valueOf(ys)).divide(BigDecimal.valueOf(12), 4, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
                        aae260 = aae851.multiply(overYears_aaa031).multiply(BigDecimal.valueOf(ys)).divide(BigDecimal.valueOf(12), 4, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
                        aae854 = aae853.multiply(overYears_aaa031).multiply(BigDecimal.valueOf(ys)).divide(BigDecimal.valueOf(12), 4, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
                    }
                } else {
                    //本金*利率
                    aae259 = aae849.multiply(overYears_aaa031).setScale(2, BigDecimal.ROUND_HALF_UP);
                    aae260 = aae851.multiply(overYears_aaa031).setScale(2, BigDecimal.ROUND_HALF_UP);
                    aae854 = aae853.multiply(overYears_aaa031).setScale(2, BigDecimal.ROUND_HALF_UP);
                    if (year.intValue() == endAae001.intValue()) {
                        Integer ys = this.aae042 % 100;
                        aae259 = aae849.multiply(overYears_aaa031).multiply(BigDecimal.valueOf(ys)).divide(BigDecimal.valueOf(12), 4, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
                        aae260 = aae851.multiply(overYears_aaa031).multiply(BigDecimal.valueOf(ys)).divide(BigDecimal.valueOf(12), 4, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
                        aae854 = aae853.multiply(overYears_aaa031).multiply(BigDecimal.valueOf(ys)).divide(BigDecimal.valueOf(12), 4, BigDecimal.ROUND_HALF_UP).setScale(2, BigDecimal.ROUND_HALF_UP);
                    }
                }*/
                IndividualAccountParameter individualAccountParameter = new IndividualAccountParameter();
                individualAccountParameter.setAaz117("");
                individualAccountParameter.setAaz116(aaz116);
                individualAccountParameter.setAaa119(aaa119);
                individualAccountParameter.setAaa513(Constant.AAA513_2_LZH);
                individualAccountParameter.setAac001(this.aac001);
                individualAccountParameter.setAae001(year);
                individualAccountParameter.setAae849(aae849);
                individualAccountParameter.setAae259(aae259);
                individualAccountParameter.setAae262(aae262);
                individualAccountParameter.setAae263(aae263);
                aae850 = aae849.add(aae259).add(aae262).add(aae263);
                individualAccountParameter.setAae850(aae850);
                individualAccountParameter.setAae851(aae851);
                individualAccountParameter.setAae260(aae260);
                individualAccountParameter.setAae264(aae264);
                individualAccountParameter.setAae265(aae265);
                aae852 = aae851.add(aae260).add(aae264).add(aae265);
                individualAccountParameter.setAae852(aae852);
                individualAccountParameter.setAae853(aae853);
                individualAccountParameter.setAae854(aae854);
                individualAccountParameter.setAae855(aae855);
                individualAccountParameter.setAae856(aae856);
                aae857 = aae853.add(aae854).add(aae855).add(aae856);
                individualAccountParameter.setAae857(aae857);
                individualAccountParameter.setAae873(aae873);
                individualAccountParameter.setAae874(aae874);
                individualAccountParameter.setAae875(aae875);
                individualAccountParameter.setAae876(aae876);
                individualAccountParameter.setAaa031(current_aaa031);
                individualAccountParameter.setAae825(Constant.AAE825_0_F);
                individualAccountParameter.setAae100(Constant.AAE100_1_YX);
                individualAccountParameter.setAaz159(this.aaz159);
                individualAccountParameter.setAae013("采集账户计息");
                individualAccountParameter.setAic376(this.aic376);
                individualAccountParameter.setAaz673(aaz116AndAaz673Map.get(aaz116));
                if (ValidateUtil.isNotEmpty(aae825MyMapll)) {//如果打着手工标志，需要加入
                    individualAccountParameter.setAae825(aae825MyMapll.get(0).getAsString("aae825"));
                }
                cjhzList.add(individualAccountParameter);
                IndividualAccountParameters.add(individualAccountParameter);
                IndividualAccountLocalitys.add(individualAccountParameter);
                MyMap ocerMap = new MyMap();
                ocerMap.put("aae849", aae849);//截至上年末个人账户单位缴费部分划转累计本息,
                ocerMap.put("aae259", aae259);//截至上年末个人账户单位缴费部分划转本息在本年产生的利息,
                ocerMap.put("aae262", aae262);//本年单位缴费部分划入个人账户本金,
                ocerMap.put("aae263", aae263);//本年单位缴费部分划入个人账户本金所产生的利息,
                ocerMap.put("aae851", aae851);//截至上年末个人账户个人缴费部分划转累计本息,
                ocerMap.put("aae260", aae260);//截至上年末个人账户个人缴费部分划转本息在本年产生的利息,
                ocerMap.put("aae264", aae264);//本年个人缴费部分划入个人账户本金,
                ocerMap.put("aae265", aae265);//本年个人缴费部分划入个人账户本金所产生的利息,
                ocerMap.put("aae853", aae853);//截至上年末个人账户其他部分划转累计本息,
                ocerMap.put("aae854", aae854);//截至上年末个人账户其他部分划转本息在本年产生的利息,
                ocerMap.put("aae855", aae855);//本年其他部分划入个人账户本金,
                ocerMap.put("aae856", aae856);//本年其他部分划入个人账户本金所产生的利息,
                ocerMap.put("aae001", year);//本年其他部分划入个人账户本金所产生的利息,
                overAllLists.add(ocerMap);
                year = year + 1;
            }

            for (IndividualAccountParameter individualAccountParameter : cjhzList) {
                aae238 = aae238.add(individualAccountParameter.getAae262()).add(individualAccountParameter.getAae264()).add(individualAccountParameter.getAae855());
                aae239 = aae239.add(individualAccountParameter.getAae259()).add(individualAccountParameter.getAae263()).add(individualAccountParameter.getAae260()).add(individualAccountParameter.getAae265()).add(individualAccountParameter.getAae854()).add(individualAccountParameter.getAae856());
            }
            aae240 = aae238.add(aae239);
            if (ValidateUtil.isNotEmpty(cjhzList)) {
                IndividualAccountParameter cjAae240 = cjhzList.stream().max(Comparator.comparing(in -> in.getAae001())).get();
                BigDecimal aae240Tz = cjAae240.getAae849().add(cjAae240.getAae259()).add(cjAae240.getAae262())
                        .add(cjAae240.getAae263()).add(cjAae240.getAae851()).add(cjAae240.getAae260()).add(cjAae240.getAae264())
                        .add(cjAae240.getAae265()).add(cjAae240.getAae853()).add(cjAae240.getAae854()).add(cjAae240.getAae855()).add(cjAae240.getAae856());
                if (aae240Tz.compareTo(aae240) != 0) {
                    BigDecimal ce = aae240Tz.subtract(aae240);
                    aae240 = aae240Tz;
                    aae239 = aae239.add(ce);
                }
            } else {
                aae240 = aae238.add(aae239);
            }
        }

        IndividualAccount individualAccount = new IndividualAccount();
        individualAccount.setAaz116(aaz116);
        individualAccount.setAac001(aac001);
        individualAccount.setAaa119(aaa119);
        individualAccount.setAac062(aac062);
        individualAccount.setAaa513(Constant.AAA513_2_LZH);
        individualAccount.setAae206(aae206);
        individualAccount.setAic376(this.aic376);
        individualAccount.setAae238(aae238);
        individualAccount.setAae239(aae239);
        individualAccount.setAae240(aae240);
        individualAccount.setAae100(Constant.AAE100_1_YX);
        individualAccount.setAaz159(aaz159);
        individualAccount.setAae013("采集账户计息");

        individualAccount.setAaz673(aaz116AndAaz673Map.get(aaz116));
        individualAccount.setAae368(Constant.AAE368_0_F);
        IndividualAccounts.add(individualAccount);
    }


    protected BigDecimal convertNullToBigDecimal(BigDecimal bigDecimal) {
        if (null == bigDecimal) {
            return BigDecimal.ZERO;
        }
        return bigDecimal;
    }

    /**
     * 保存账户
     */
    public void saveAccount(List<IndividualAccount> individualAccount, List<IndividualAccountParameter> individualAccountParameter) {

        //删除ac50
        List<String> aaz116 = ListUtil.listMyMap2ListString(ListUtil.list2MyMapList(individualAccount), "aaz116");
        accountAc50Mapper.deleteBatchIds(aaz116);

        //删除ac51
        QueryWrapper<AccountAc51> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("aaz116", aaz116);
        accountAc51Mapper.delete(queryWrapper);
        BigDecimal date = new BigDecimal(DateUtil.getCurrentTime("yyyyMMdd"));

        ArrayList<AccountAc50> accountAc50List = new ArrayList<>();

        for (IndividualAccount account : individualAccount) {
            AccountAc50 accountAc50 = new AccountAc50();

            accountAc50.setAaz116(account.getAaz116());
            accountAc50.setAac001(account.getAac001());
            accountAc50.setAaa119(account.getAaa119());
            accountAc50.setAac062(account.getAac062());
            accountAc50.setAaa513(account.getAaa513());
            if(!ValidateUtil.isEmpty(account.getAae206())){
            accountAc50.setAae206( new BigDecimal(account.getAae206()));
            }
            if(!ValidateUtil.isEmpty(account.getAae237())) {
            accountAc50.setAae237(new BigDecimal(account.getAae237()));
            }
            if(!ValidateUtil.isEmpty(account.getAic376())) {
            accountAc50.setAic376(new BigDecimal(account.getAic376()));
            }
            accountAc50.setAae238(account.getAae238());
            accountAc50.setAae239(account.getAae239());
            accountAc50.setAae240(account.getAae240());
            accountAc50.setAae368(account.getAae368());
            accountAc50.setAae100(account.getAae100());
            accountAc50.setAaz159(account.getAaz159());
            accountAc50.setAae013(account.getAae013());
            accountAc50.setAae011(SecurityUtils.getCurrentUsername());
            accountAc50.setAae036(date);
            accountAc50.setAab359("530111");
            accountAc50List.add(accountAc50);

        }


        ArrayList<AccountAc51> accountAc51List = new ArrayList<>();

        for (IndividualAccountParameter accountParameter : individualAccountParameter) {
            AccountAc51 accountAc51 = new AccountAc51();
            accountAc51.setAaz117(accountParameter.getAaz117());
            accountAc51.setAaz116(accountParameter.getAaz116());
            accountAc51.setAaa119(accountParameter.getAaa119());
            accountAc51.setAaa513(accountParameter.getAaa513());
            accountAc51.setAic376(new BigDecimal(accountParameter.getAic376()));
            accountAc51.setAac001(accountParameter.getAac001());
            accountAc51.setAae001(new BigDecimal(accountParameter.getAae001()));
            accountAc51.setAae849(accountParameter.getAae849());
            accountAc51.setAae259(accountParameter.getAae259());
            accountAc51.setAae262(accountParameter.getAae262());
            accountAc51.setAae263(accountParameter.getAae263());
            accountAc51.setAae850(accountParameter.getAae850());
            accountAc51.setAae851(accountParameter.getAae851());
            accountAc51.setAae260(accountParameter.getAae260());
            accountAc51.setAae264(accountParameter.getAae264());
            accountAc51.setAae265(accountParameter.getAae265());
            accountAc51.setAae852(accountParameter.getAae852());
            accountAc51.setAae853(accountParameter.getAae853());
            accountAc51.setAae854(accountParameter.getAae854());
            accountAc51.setAae855(accountParameter.getAae855());
            accountAc51.setAae856(accountParameter.getAae856());
            accountAc51.setAae857(accountParameter.getAae857());
            accountAc51.setAae873(accountParameter.getAae873());
            accountAc51.setAae874(accountParameter.getAae874());
            accountAc51.setAae875(accountParameter.getAae875());
            accountAc51.setAae876(accountParameter.getAae876());
            accountAc51.setAaa031(accountParameter.getAaa031());
            accountAc51.setAae825(accountParameter.getAae825());
            accountAc51.setAae100(accountParameter.getAae100());
            accountAc51.setAaz159(accountParameter.getAaz159());
            accountAc51.setAae013(accountParameter.getAae013());
            accountAc51.setAae011(SecurityUtils.getCurrentUsername());
            accountAc51.setAae036(date);
            accountAc51.setAab359("530111");
            accountAc51List.add(accountAc51);

        }

        accountAc50Service.saveBatch(accountAc50List);


        accountAc51Service.saveBatch(accountAc51List);
    }


}
